├── Heap-Layers ├── COPYING ├── README.md ├── TODO ├── heaplayers.h ├── heaps │ ├── README │ ├── all.h │ ├── buildingblock │ │ ├── adaptheap.h │ │ ├── all.h │ │ ├── boundedfreelistheap.h │ │ ├── chunkheap.h │ │ ├── coalesceheap.h │ │ └── freelistheap.h │ ├── combining │ │ ├── all.h │ │ ├── hybridheap.h │ │ ├── segheap.h │ │ ├── strictsegheap.h │ │ └── tryheap.h │ ├── debug │ │ ├── all.h │ │ ├── checkheap.h │ │ ├── debugheap.h │ │ ├── logheap.h │ │ ├── sanitycheckheap.h │ │ └── statsheap.h │ ├── general │ │ ├── all.h │ │ ├── dlheap.h │ │ ├── kingsleyheap.h │ │ └── leamallocheap.h │ ├── objectrep │ │ ├── addheap.h │ │ ├── all.h │ │ ├── coalesceableheap.h │ │ ├── sizeheap.h │ │ └── sizeownerheap.h │ ├── special │ │ ├── all.h │ │ ├── bumpalloc.h │ │ ├── nestedheap.h │ │ ├── obstack.h │ │ ├── obstackheap.h │ │ ├── obstackreap.h │ │ ├── sbrk.c │ │ ├── xallocheap.h │ │ └── zoneheap.h │ ├── threads │ │ ├── all.h │ │ ├── lockedheap.h │ │ ├── phothreadheap.h │ │ ├── sizethreadheap.h │ │ ├── threadheap.h │ │ └── threadspecificheap.h │ ├── top │ │ ├── all.h │ │ ├── mallocheap.h │ │ ├── mmapheap.h │ │ ├── sbrkheap.h │ │ └── staticheap.h │ └── utility │ │ ├── all.h │ │ ├── exceptionheap.h │ │ ├── localmallocheap.h │ │ ├── nullheap.h │ │ ├── old │ │ └── oneheap.h │ │ ├── oneheap.h │ │ ├── perclassheap.h │ │ ├── profileheap.h │ │ ├── slopheap.h │ │ ├── traceheap.h │ │ └── uniqueheap.h ├── locks │ ├── all.h │ ├── maclock.h │ ├── posixlock.h │ ├── recursivelock.h │ ├── spinlock.h │ └── winlock.h ├── threads │ ├── all.h │ ├── cpuinfo.h │ └── fred.h ├── utility │ ├── a.out │ ├── align.h │ ├── all.h │ ├── bins.h │ ├── bins16k.h │ ├── bins4k.h │ ├── bins64k.h │ ├── bins8k.h │ ├── dllist.h │ ├── dynarray.h │ ├── freesllist.h │ ├── gcd.h │ ├── guard.h │ ├── hash.h │ ├── istrue.h │ ├── lcm.h │ ├── myhashmap.h │ ├── sassert.h │ ├── singleton.h │ ├── sllist.h │ ├── testalign.cpp │ └── timer.h └── wrappers │ ├── all.h │ ├── ansiwrapper.h │ ├── arch-specific │ ├── sparc-interchange.il │ ├── x86-interchange.il │ └── x86_64-interchange.il │ ├── gnuwrapper.cpp │ ├── macinterpose.h │ ├── macwrapper.cpp │ ├── mallocinfo.h │ ├── mmapwrapper.h │ ├── stlallocator.h │ ├── winwrapper.cpp │ └── wrapper.cpp ├── README.md ├── allocators ├── CAMA │ ├── Makefile │ ├── ansiwrapper.h │ ├── bitops.h │ ├── cama-driver.cpp │ ├── camarea.h │ ├── camarea2.c │ ├── libcama.cpp │ └── malloc-test.c ├── TLSF │ └── TLSF-2.4.6 │ │ ├── COPYING │ │ ├── Changelog │ │ ├── GPL.txt │ │ ├── LGPL-2.1.txt │ │ ├── README │ │ ├── TODO │ │ ├── examples │ │ ├── Makefile │ │ ├── test.c │ │ ├── test1.c │ │ ├── test2.c │ │ ├── test3.c │ │ └── test4.c │ │ └── src │ │ ├── Makefile │ │ ├── target.h │ │ ├── tlsf-shim.cpp │ │ ├── tlsf.c │ │ └── tlsf.h ├── dlmalloc │ ├── dlmalloc272 │ │ ├── compile │ │ ├── compile-nolocks │ │ ├── dlmalloc.c │ │ └── libdlmalloc.cpp │ ├── dlmalloc282 │ │ ├── compile │ │ ├── compile-nolocks │ │ ├── dlmalloc.c │ │ └── libdlmalloc.cpp │ └── dlmalloc285 │ │ ├── compile │ │ ├── dlmalloc.c │ │ └── libdlmalloc.cpp ├── jemalloc │ ├── compile │ ├── jemalloc.c │ └── tree.h ├── kmalloc │ ├── compile │ ├── kmalloc.c │ └── libkmalloc.cpp ├── nedmalloc │ ├── Benchmarks.xls │ ├── License.txt │ ├── Readme.txt │ ├── malloc.c.h │ ├── nedmalloc.c │ ├── nedmalloc.h │ ├── nedmalloc.sln │ ├── nedmalloc.vcproj │ └── test.c ├── old │ └── streamflow │ │ ├── Makefile │ │ ├── README │ │ ├── include-ppc64 │ │ ├── atomic.h │ │ └── bitops.h │ │ ├── include-x86 │ │ ├── atomic.h │ │ └── bitops.h │ │ ├── lock.h │ │ ├── malloc_new.cpp │ │ ├── malloc_new.h │ │ ├── override.c │ │ ├── queue.h │ │ ├── recycle.c │ │ ├── streamflow.c │ │ └── streamflow.h ├── omalloc │ ├── Makefile │ ├── gnuwrapper.cpp │ ├── issetugid.c │ ├── omalloc.c │ └── random.c ├── ottomalloc │ ├── Makefile │ ├── arc4random.c │ ├── libottomalloc.cpp │ ├── ottomalloc_linux.c │ └── ottomallocheap.h ├── phkmalloc │ ├── Makefile │ ├── compile │ ├── libphk.cpp │ ├── libphkmalloc.cpp │ ├── phkmalloc.c │ ├── phkmalloc_linux.c │ ├── phkmalloc_reap.c │ ├── phkmalloc_sc.c │ ├── phkmalloc_sc_reap.c │ ├── phkmallocheap.h │ └── sealer.cpp ├── ptmalloc │ ├── ptmalloc2 │ │ ├── COPYRIGHT │ │ ├── ChangeLog │ │ ├── Makefile │ │ ├── README │ │ ├── arena.c │ │ ├── compile │ │ ├── hooks.c │ │ ├── libptmalloc.cpp │ │ ├── lran2.h │ │ ├── malloc.c │ │ ├── malloc.h │ │ ├── t-test.h │ │ ├── t-test1.c │ │ ├── t-test2.c │ │ ├── thread-m.h │ │ ├── thread-st.h │ │ └── tst-mallocstate.c │ └── ptmalloc3 │ │ ├── COPYRIGHT │ │ ├── ChangeLog │ │ ├── Makefile │ │ ├── README │ │ ├── compile │ │ ├── lran2.h │ │ ├── malloc-2.8.3.h │ │ ├── malloc-private.h │ │ ├── malloc.c │ │ ├── ptmalloc3.c │ │ ├── sysdeps │ │ ├── generic │ │ │ ├── atomic.h │ │ │ ├── malloc-machine.h │ │ │ └── thread-st.h │ │ ├── pthread │ │ │ ├── malloc-machine.h │ │ │ └── thread-st.h │ │ ├── solaris │ │ │ ├── malloc-machine.h │ │ │ └── thread-st.h │ │ └── sproc │ │ │ ├── malloc-machine.h │ │ │ └── thread-st.h │ │ ├── t-test.h │ │ ├── t-test1.c │ │ ├── t-test2.c │ │ └── tst-independent-alloc.c ├── streamflow │ └── streamflow │ │ ├── Makefile │ │ ├── README │ │ ├── include-ia64 │ │ ├── atomic.h │ │ ├── bitops.h │ │ └── queue.h │ │ ├── include-ppc64 │ │ ├── atomic.h │ │ ├── bitops.h │ │ └── queue.h │ │ ├── include-x86 │ │ ├── atomic.h │ │ ├── bitops.h │ │ └── queue.h │ │ ├── include-x86_64 │ │ ├── atomic.h │ │ ├── bitops.h │ │ └── queue.h │ │ ├── larson-30_7-8 │ │ ├── larson.cpp │ │ ├── lock.h │ │ ├── malloc_new.cpp │ │ ├── override.c │ │ ├── recycle.c │ │ ├── streamflow.c │ │ └── streamflow.h └── tcmalloc │ └── google-perftools-0.91 │ ├── .deps │ ├── addressmap_unittest-addressmap_unittest.Po │ ├── atomicops-internals-x86.Plo │ ├── atomicops_unittest.Po │ ├── frag_unittest-frag_unittest.Po │ ├── heap_checker_unittest-heap-checker_unittest.Po │ ├── heap_profiler_unittest-heap-profiler_unittest.Po │ ├── libtcmalloc_la-heap-checker-bcad.Plo │ ├── libtcmalloc_la-heap-checker.Plo │ ├── libtcmalloc_la-heap-profile-table.Plo │ ├── libtcmalloc_la-heap-profiler.Plo │ ├── libtcmalloc_la-internal_logging.Plo │ ├── libtcmalloc_la-low_level_alloc.Plo │ ├── libtcmalloc_la-malloc_extension.Plo │ ├── libtcmalloc_la-malloc_hook.Plo │ ├── libtcmalloc_la-maybe_threads.Plo │ ├── libtcmalloc_la-memory_region_map.Plo │ ├── libtcmalloc_la-sysinfo.Plo │ ├── libtcmalloc_la-system-alloc.Plo │ ├── libtcmalloc_la-tcmalloc.Plo │ ├── libtcmalloc_minimal_la-internal_logging.Plo │ ├── libtcmalloc_minimal_la-malloc_extension.Plo │ ├── libtcmalloc_minimal_la-malloc_hook.Plo │ ├── libtcmalloc_minimal_la-maybe_threads.Plo │ ├── libtcmalloc_minimal_la-system-alloc.Plo │ ├── libtcmalloc_minimal_la-tcmalloc.Plo │ ├── linuxthreads.Plo │ ├── logging.Plo │ ├── low_level_alloc.Po │ ├── low_level_alloc_unittest.Po │ ├── malloc_hook.Po │ ├── markidle_unittest-markidle_unittest.Po │ ├── markidle_unittest-testutil.Po │ ├── memalign_unittest-memalign_unittest.Po │ ├── mutex.Plo │ ├── profiler.Plo │ ├── profiler1_unittest-profiler_unittest.Po │ ├── profiler2_unittest-profiler_unittest.Po │ ├── profiler3_unittest-profiler_unittest.Po │ ├── profiler4_unittest-profiler_unittest.Po │ ├── ptmalloc_unittest1-t-test1.Po │ ├── ptmalloc_unittest2-t-test2.Po │ ├── spinlock.Plo │ ├── stacktrace.Plo │ ├── stacktrace_unittest.Po │ ├── tcmalloc_both_unittest-tcmalloc_unittest.Po │ ├── tcmalloc_large_unittest-tcmalloc_large_unittest.Po │ ├── tcmalloc_minimal_large_unittest-tcmalloc_large_unittest.Po │ ├── tcmalloc_minimal_unittest-tcmalloc_unittest.Po │ ├── tcmalloc_unittest-tcmalloc_unittest.Po │ ├── thread_dealloc_unittest-testutil.Po │ ├── thread_dealloc_unittest-thread_dealloc_unittest.Po │ └── thread_lister.Plo │ ├── AUTHORS │ ├── COPYING │ ├── ChangeLog │ ├── INSTALL │ ├── Makefile │ ├── Makefile.am │ ├── Makefile.in │ ├── NEWS │ ├── README │ ├── TODO │ ├── aclocal.m4 │ ├── compile │ ├── config.guess │ ├── config.log │ ├── config.status │ ├── config.sub │ ├── configure │ ├── configure.ac │ ├── depcomp │ ├── doc │ ├── cpuprofile.html │ ├── designstyle.css │ ├── heap-example1.png │ ├── heap_checker.html │ ├── heapprofile.html │ ├── index.html │ ├── overview.dot │ ├── overview.gif │ ├── pageheap.dot │ ├── pageheap.gif │ ├── pprof-test-big.gif │ ├── pprof-test.gif │ ├── pprof-vsnprintf-big.gif │ ├── pprof-vsnprintf.gif │ ├── pprof.1 │ ├── pprof_remote_servers.html │ ├── spanmap.dot │ ├── spanmap.gif │ ├── t-test1.times.txt │ ├── tcmalloc-opspercpusec.vs.threads.1024.bytes.png │ ├── tcmalloc-opspercpusec.vs.threads.128.bytes.png │ ├── tcmalloc-opspercpusec.vs.threads.131072.bytes.png │ ├── tcmalloc-opspercpusec.vs.threads.16384.bytes.png │ ├── tcmalloc-opspercpusec.vs.threads.2048.bytes.png │ ├── tcmalloc-opspercpusec.vs.threads.256.bytes.png │ ├── tcmalloc-opspercpusec.vs.threads.32768.bytes.png │ ├── tcmalloc-opspercpusec.vs.threads.4096.bytes.png │ ├── tcmalloc-opspercpusec.vs.threads.512.bytes.png │ ├── tcmalloc-opspercpusec.vs.threads.64.bytes.png │ ├── tcmalloc-opspercpusec.vs.threads.65536.bytes.png │ ├── tcmalloc-opspercpusec.vs.threads.8192.bytes.png │ ├── tcmalloc-opspersec.vs.size.1.threads.png │ ├── tcmalloc-opspersec.vs.size.12.threads.png │ ├── tcmalloc-opspersec.vs.size.16.threads.png │ ├── tcmalloc-opspersec.vs.size.2.threads.png │ ├── tcmalloc-opspersec.vs.size.20.threads.png │ ├── tcmalloc-opspersec.vs.size.3.threads.png │ ├── tcmalloc-opspersec.vs.size.4.threads.png │ ├── tcmalloc-opspersec.vs.size.5.threads.png │ ├── tcmalloc-opspersec.vs.size.8.threads.png │ ├── tcmalloc.html │ ├── threadheap.dot │ └── threadheap.gif │ ├── install-sh │ ├── libtool │ ├── ltmain.sh │ ├── missing │ ├── mkinstalldirs │ ├── packages │ ├── deb.sh │ ├── deb │ │ ├── README │ │ ├── changelog │ │ ├── compat │ │ ├── control │ │ ├── copyright │ │ ├── docs │ │ ├── libgoogle-perftools-dev.dirs │ │ ├── libgoogle-perftools-dev.install │ │ ├── libgoogle-perftools0.dirs │ │ ├── libgoogle-perftools0.install │ │ ├── libgoogle-perftools0.manpages │ │ └── rules │ ├── rpm.sh │ └── rpm │ │ └── rpm.spec │ └── src │ ├── addressmap-inl.h │ ├── base │ ├── atomicops-internals-macosx.h │ ├── atomicops-internals-x86-msvc.h │ ├── atomicops-internals-x86.cc │ ├── atomicops-internals-x86.h │ ├── atomicops.h │ ├── basictypes.h │ ├── commandlineflags.h │ ├── elfcore.h │ ├── googleinit.h │ ├── linux_syscall_support.h │ ├── linuxthreads.c │ ├── linuxthreads.h │ ├── logging.cc │ ├── logging.h │ ├── low_level_alloc.cc │ ├── low_level_alloc.h │ ├── mutex.cc │ ├── mutex.h │ ├── spinlock.cc │ ├── spinlock.h │ ├── stl_allocator.h │ ├── sysinfo.cc │ ├── sysinfo.h │ ├── thread_lister.c │ └── thread_lister.h │ ├── config.h │ ├── config.h.in │ ├── google │ ├── heap-checker.h │ ├── heap-profiler.h │ ├── malloc_extension.h │ ├── malloc_hook.h │ ├── perftools │ │ └── hash_set.h │ ├── profiler.h │ └── stacktrace.h │ ├── heap-checker-bcad.cc │ ├── heap-checker.cc │ ├── heap-profile-table.cc │ ├── heap-profile-table.h │ ├── heap-profiler.cc │ ├── internal_logging.cc │ ├── internal_logging.h │ ├── malloc_extension.cc │ ├── malloc_hook.cc │ ├── maybe_threads.cc │ ├── maybe_threads.h │ ├── memory_region_map.cc │ ├── memory_region_map.h │ ├── pagemap.h │ ├── pprof │ ├── profiler.cc │ ├── stacktrace.cc │ ├── stacktrace_generic-inl.h │ ├── stacktrace_libunwind-inl.h │ ├── stacktrace_x86-inl.h │ ├── stacktrace_x86_64-inl.h │ ├── stamp-h1 │ ├── system-alloc.cc │ ├── system-alloc.h │ ├── tcmalloc.cc │ └── tests │ ├── addressmap_unittest.cc │ ├── atomicops_unittest.cc │ ├── frag_unittest.cc │ ├── heap-checker-death_unittest.sh │ ├── heap-checker_unittest.cc │ ├── heap-checker_unittest.sh │ ├── heap-profiler_unittest.cc │ ├── heap-profiler_unittest.sh │ ├── low_level_alloc_unittest.cc │ ├── markidle_unittest.cc │ ├── memalign_unittest.cc │ ├── profiler_unittest.cc │ ├── profiler_unittest.sh │ ├── ptmalloc │ ├── lran2.h │ ├── malloc-machine.h │ ├── t-test.h │ ├── t-test1.c │ ├── t-test2.c │ ├── thread-m.h │ └── thread-st.h │ ├── stacktrace_unittest.cc │ ├── tcmalloc_large_unittest.cc │ ├── tcmalloc_unittest.cc │ ├── testutil.cc │ ├── testutil.h │ └── thread_dealloc_unittest.cc └── util └── heapshield.cpp /Heap-Layers/README.md: -------------------------------------------------------------------------------- 1 | [Heap Layers: An Extensible Memory Allocation Infrastructure](http://www.heaplayers.org) 2 | ----------------------------------------------------------- 3 | 4 | Copyright (C) 2000 - 2012 by [Emery Berger](http://www.cs.umass.edu/~emery) 5 | 6 | Please read [COPYING](heaplayers/COPYING) for licensing information. 7 | 8 | Heap Layers is distributed under the terms of the GNU General Public License. 9 | 10 | **Commercial licenses are also available.** 11 | 12 | Please contact Emery Berger (emery@cs.umass.edu) for more details. 13 | 14 | ## Introduction ## 15 | 16 | Heap Layers provides a flexible infrastructure for composing 17 | high-performance memory allocators out of C++ _layers_. Heap Layers 18 | makes it easy to write high-quality custom and general-purpose 19 | memory allocators. Heap Layers has been used successfully to build 20 | a number of high-performance allocators, including [Hoard](http://www.hoard.org) and [DieHard](http://www.diehard-software.org/). 21 | 22 | ## Using Heap Layers ## 23 | 24 | For an introduction to Heap Layers, read the article [Policy-Based 25 | Memory Allocation](http://www.drdobbs.com/184402039), by Andrei 26 | Alexandrescu and Emery Berger. It's a good overview. 27 | 28 | Heap Layers contains a number of ready-made heap components that can 29 | be plugged together with minimal effort, and the result is often 30 | faster than hand-built allocators. The PLDI 2001 paper [Composing 31 | High-Performance Memory 32 | Allocators](http://www.cs.umass.edu/~emery/pubs/berger-pldi2001.pdf) 33 | has plenty of examples. 34 | 35 | ## Performance ## 36 | 37 | Heap Layers can substantially outperform its only real competitor, 38 | the Vmalloc package from AT&T. The OOPSLA 2002 paper [Reconsidering 39 | Custom Memory 40 | Allocation](http://www.cs.umass.edu/~emery/pubs/berger-oopsla2002.pdf) 41 | paper has more details. 42 | 43 | Not only is Heap Layers much higher level and simpler to use, but 44 | its use of templates also improves performance. Heap Layers both 45 | eliminates the function call overhead imposed by Vmalloc layers and 46 | yields higher quality code by exposing more optimization 47 | opportunities. 48 | 49 | -------------------------------------------------------------------------------- /Heap-Layers/TODO: -------------------------------------------------------------------------------- 1 | - Make MyHashMap dynamic. 2 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/README: -------------------------------------------------------------------------------- 1 | Heap organization: 2 | 3 | top/ - "source" heaps that have no superheap. 4 | combining/ - heaps whose purpose is to combine two existing superheaps. 5 | debug/ - heaps whose only purpose is debugging or statistics-gathering. 6 | threads/ - heaps designed to support multiple threads. 7 | special/ - esoteric heaps to support custom allocation schemes like obstacks. 8 | 9 | buildingblock/ - layers that cannot be used standalone but rather are useful for building other heaps. 10 | objectrep/ - heaps that change the representation of individual objects (e.g., by adding headers). 11 | (admittedly this is a terrible organizational principle) 12 | utility/ - currently a grab-bag 13 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/all.h: -------------------------------------------------------------------------------- 1 | #include "buildingblock/all.h" 2 | #include "debug/all.h" 3 | #include "objectrep/all.h" 4 | #include "threads/all.h" 5 | #include "utility/all.h" 6 | #include "combining/all.h" 7 | #include "general/all.h" 8 | #include "top/all.h" 9 | #include "special/all.h" 10 | 11 | 12 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/buildingblock/all.h: -------------------------------------------------------------------------------- 1 | #include "adaptheap.h" 2 | #include "boundedfreelistheap.h" 3 | #include "chunkheap.h" 4 | #include "coalesceheap.h" 5 | #include "freelistheap.h" 6 | 7 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/buildingblock/boundedfreelistheap.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | #ifndef _BOUNDEDFREELISTHEAP_H_ 4 | #define _BOUNDEDFREELISTHEAP_H_ 5 | 6 | // Beware -- this is for one "size class" only!! 7 | 8 | template 9 | class BoundedFreeListHeap : public Super { 10 | public: 11 | 12 | BoundedFreeListHeap (void) 13 | : nObjects (0), 14 | myFreeList (NULL) 15 | {} 16 | 17 | ~BoundedFreeListHeap (void) 18 | { 19 | clear(); 20 | } 21 | 22 | inline void * malloc (size_t sz) { 23 | // Check the free list first. 24 | void * ptr = myFreeList; 25 | if (ptr == NULL) { 26 | ptr = Super::malloc (sz); 27 | } else { 28 | myFreeList = myFreeList->next; 29 | } 30 | return ptr; 31 | } 32 | 33 | inline void free (void * ptr) { 34 | if (nObjects < numObjects) { 35 | // Add this object to the free list. 36 | ((freeObject *) ptr)->next = myFreeList; 37 | myFreeList = (freeObject *) ptr; 38 | nObjects++; 39 | } else { 40 | clear(); 41 | // Super::free (ptr); 42 | } 43 | } 44 | 45 | inline void clear (void) { 46 | // Delete everything on the free list. 47 | void * ptr = myFreeList; 48 | while (ptr != NULL) { 49 | void * oldptr = ptr; 50 | ptr = (void *) ((freeObject *) ptr)->next; 51 | Super::free (oldptr); 52 | } 53 | myFreeList = NULL; 54 | nObjects = 0; 55 | } 56 | 57 | private: 58 | 59 | class freeObject { 60 | public: 61 | freeObject * next; 62 | }; 63 | 64 | int nObjects; 65 | freeObject * myFreeList; 66 | }; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/buildingblock/freelistheap.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_FREELISTHEAP_H 28 | #define HL_FREELISTHEAP_H 29 | 30 | /** 31 | * @class FreelistHeap 32 | * @brief Manage freed memory on a linked list. 33 | * @warning This is for one "size class" only. 34 | * 35 | * Note that the linked list is threaded through the freed objects, 36 | * meaning that such objects must be at least the size of a pointer. 37 | */ 38 | 39 | #include 40 | #include "utility/freesllist.h" 41 | 42 | #ifndef NULL 43 | #define NULL 0 44 | #endif 45 | 46 | namespace HL { 47 | 48 | template 49 | class FreelistHeap : public SuperHeap { 50 | public: 51 | 52 | inline void * malloc (size_t sz) { 53 | // Check the free list first. 54 | void * ptr = _freelist.get(); 55 | // If it's empty, get more memory; 56 | // otherwise, advance the free list pointer. 57 | if (ptr == 0) { 58 | ptr = SuperHeap::malloc (sz); 59 | } 60 | return ptr; 61 | } 62 | 63 | inline void free (void * ptr) { 64 | if (ptr == 0) { 65 | return; 66 | } 67 | _freelist.insert (ptr); 68 | } 69 | 70 | inline void clear (void) { 71 | void * ptr; 72 | while ((ptr = _freelist.get())) { 73 | SuperHeap::free (ptr); 74 | } 75 | } 76 | 77 | private: 78 | 79 | FreeSLList _freelist; 80 | 81 | }; 82 | 83 | } 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/combining/all.h: -------------------------------------------------------------------------------- 1 | #include "hybridheap.h" 2 | #include "segheap.h" 3 | #include "strictsegheap.h" 4 | #include "tryheap.h" 5 | 6 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/combining/hybridheap.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_HYBRIDHEAP_H 28 | #define HL_HYBRIDHEAP_H 29 | 30 | #include 31 | 32 | #include "utility/sassert.h" 33 | #include "utility/gcd.h" 34 | 35 | /** 36 | * @class HybridHeap 37 | * Objects no bigger than BigSize are allocated and freed to SmallHeap. 38 | * Bigger objects are passed on to the super heap. 39 | */ 40 | 41 | namespace HL { 42 | 43 | template 44 | class HybridHeap : public SmallHeap { 45 | public: 46 | 47 | HybridHeap (void) 48 | { 49 | } 50 | 51 | enum { Alignment = gcd<(int) SmallHeap::Alignment, (int) BigHeap::Alignment>::value }; 52 | 53 | MALLOC_FUNCTION INLINE void * malloc (size_t sz) { 54 | void * ptr; 55 | if (sz <= BigSize) { 56 | ptr = SmallHeap::malloc (sz); 57 | } else { 58 | ptr = slowPath (sz); 59 | } 60 | assert (SmallHeap::getSize(ptr) >= sz); 61 | assert ((size_t) ptr % Alignment == 0); 62 | return ptr; 63 | } 64 | 65 | inline void free (void * ptr) { 66 | if (SmallHeap::getSize(ptr) <= BigSize) { 67 | SmallHeap::free (ptr); 68 | } else { 69 | bm.free (ptr); 70 | } 71 | } 72 | 73 | inline void clear (void) { 74 | bm.clear(); 75 | SmallHeap::clear(); 76 | } 77 | 78 | 79 | private: 80 | 81 | MALLOC_FUNCTION NO_INLINE 82 | void * slowPath (size_t sz) { 83 | return bm.malloc (sz); 84 | } 85 | 86 | 87 | HL::sassert<(BigSize > 0)> checkBigSizeNonZero; 88 | 89 | BigHeap bm; 90 | }; 91 | 92 | } 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/combining/tryheap.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_TRYHEAP_H 28 | #define HL_TRYHEAP_H 29 | 30 | namespace HL { 31 | 32 | template 33 | class TryHeap : public Heap2 { 34 | public: 35 | 36 | TryHeap (void) 37 | {} 38 | 39 | inline void * malloc (size_t sz) { 40 | void * ptr = heap1.malloc (sz); 41 | if (ptr == NULL) 42 | ptr = Heap2::malloc (sz); 43 | return ptr; 44 | } 45 | 46 | inline void free (void * ptr) { 47 | heap1.free (ptr); 48 | } 49 | 50 | private: 51 | Heap1 heap1; 52 | }; 53 | 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/debug/all.h: -------------------------------------------------------------------------------- 1 | #include "checkheap.h" 2 | #include "debugheap.h" 3 | #include "logheap.h" 4 | #include "sanitycheckheap.h" 5 | #include "statsheap.h" 6 | 7 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/debug/checkheap.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef HL_CHECKHEAP_H 4 | #define HL_CHECKHEAP_H 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * @class CheckHeap 14 | * @brief Performs simple checks on memory allocations. 15 | * 16 | **/ 17 | 18 | namespace HL { 19 | 20 | template 21 | class CheckHeap : public SuperHeap { 22 | private: 23 | 24 | enum { RECEIVED_A_NULL_OBJECT_FROM_MALLOC = 0 }; 25 | enum { RECEIVED_AN_UNALIGNED_OBJECT_FROM_MALLOC = 0 }; 26 | 27 | public: 28 | 29 | inline void * malloc (size_t sz) { 30 | void * addr = SuperHeap::malloc (sz); 31 | #if !defined(NDEBUG) 32 | 33 | // Check for null (this should in general not happen). 34 | if (addr == NULL) { 35 | assert (RECEIVED_A_NULL_OBJECT_FROM_MALLOC); 36 | printf ("RECEIVED_A_NULL_OBJECT_FROM_MALLOC\n"); 37 | abort(); 38 | } 39 | // Ensure object size is correct. 40 | assert (SuperHeap::getSize(addr) >= sz); 41 | 42 | // Check alignment. 43 | if ((unsigned long) addr % SuperHeap::Alignment != 0) { 44 | assert (RECEIVED_AN_UNALIGNED_OBJECT_FROM_MALLOC); 45 | printf ("RECEIVED_AN_UNALIGNED_OBJECT_FROM_MALLOC\n"); 46 | abort(); 47 | } 48 | 49 | // Wipe out the old contents. 50 | std::memset (addr, 0, SuperHeap::getSize(addr)); 51 | #endif 52 | return addr; 53 | } 54 | 55 | inline void free (void * ptr) { 56 | #if !defined(NDEBUG) 57 | // Wipe out the old contents. 58 | std::memset (ptr, 0, SuperHeap::getSize(ptr)); 59 | #endif 60 | SuperHeap::free (ptr); 61 | } 62 | 63 | }; 64 | 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/debug/debugheap.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | 4 | #ifndef HL_DEBUGHEAP_H_ 5 | #define HL_DEBUGHEAP_H_ 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | * 12 | * 13 | */ 14 | 15 | namespace HL { 16 | 17 | template 19 | class DebugHeap : public Super { 20 | private: 21 | 22 | enum { CANARY = 0xdeadbeef }; 23 | 24 | public: 25 | 26 | // Fill with A's. 27 | inline void * malloc (size_t sz) { 28 | // Add a guard area at the end. 29 | void * ptr; 30 | ptr = Super::malloc (sz + sizeof(unsigned long)); 31 | for (unsigned long i = 0; i < sz; i++) { 32 | ((char *) ptr)[i] = 'A'; 33 | } 34 | *((unsigned long *) ((char *) ptr + sz)) = (unsigned long) CANARY; 35 | assert (Super::getSize(ptr) >= sz); 36 | return ptr; 37 | } 38 | 39 | // Fill with F's. 40 | inline void free (void * ptr) { 41 | char * b = (char *) ptr; 42 | size_t sz = Super::getSize(ptr); 43 | // Check for the canary. 44 | unsigned long storedCanary = *((unsigned long *) b + sz - sizeof(unsigned long)); 45 | if (storedCanary != CANARY) { 46 | abort(); 47 | } 48 | for (unsigned int i = 0; i < sz; i++) { 49 | ((char *) ptr)[i] = freeChar; 50 | } 51 | Super::free (ptr); 52 | } 53 | }; 54 | 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/general/all.h: -------------------------------------------------------------------------------- 1 | #include "dlheap.h" 2 | #include "kingsleyheap.h" 3 | #include "leamallocheap.h" 4 | 5 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/general/leamallocheap.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2003 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_LEAMALLOCHEAP_H 28 | #define HL_LEAMALLOCHEAP_H 29 | 30 | #include 31 | 32 | /** 33 | * @class LeaMallocHeap 34 | * @brief A "source heap" that uses the Lea allocator. 35 | */ 36 | 37 | extern "C" void * dlmalloc (size_t); 38 | extern "C" void dlfree (void *); 39 | extern "C" size_t dlmalloc_usable_size (void *); 40 | 41 | namespace HL { 42 | 43 | class LeaMallocHeap { 44 | public: 45 | inline void * malloc (size_t sz) { 46 | void * ptr = dlmalloc (sz); 47 | return ptr; 48 | } 49 | 50 | inline void free (void * p) { 51 | dlfree (p); 52 | } 53 | 54 | inline size_t getSize (const void * p) { 55 | return dlmalloc_usable_size ((void *) p); 56 | } 57 | }; 58 | 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/objectrep/addheap.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | #ifndef HL_ADDHEAP_H 4 | #define HL_ADDHEAP_H 5 | 6 | /* 7 | 8 | Heap Layers: An Extensible Memory Allocation Infrastructure 9 | 10 | Copyright (C) 2000-2012 by Emery Berger 11 | http://www.cs.umass.edu/~emery 12 | emery@cs.umass.edu 13 | 14 | This program is free software; you can redistribute it and/or modify 15 | it under the terms of the GNU General Public License as published by 16 | the Free Software Foundation; either version 2 of the License, or 17 | (at your option) any later version. 18 | 19 | This program is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | GNU General Public License for more details. 23 | 24 | You should have received a copy of the GNU General Public License 25 | along with this program; if not, write to the Free Software 26 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 27 | 28 | */ 29 | 30 | // Reserve space for a class in the head of every allocated object. 31 | 32 | #include 33 | #include "utility/lcm.h" 34 | 35 | namespace HL { 36 | 37 | template 38 | class AddHeap : public SuperHeap { 39 | public: 40 | 41 | inline void * malloc (size_t sz) { 42 | void * ptr = SuperHeap::malloc (sz + HeaderSize); 43 | void * newPtr = (char *) ptr + HeaderSize; 44 | return newPtr; 45 | } 46 | 47 | inline void free (void * ptr) { 48 | SuperHeap::free (getOriginal(ptr)); 49 | } 50 | 51 | inline size_t getSize (void * ptr) { 52 | return SuperHeap::getSize (getOriginal(ptr)); 53 | } 54 | 55 | private: 56 | 57 | inline void * getOriginal (void * ptr) { 58 | void * origPtr = (void *) ((char *) ptr - HeaderSize); 59 | return origPtr; 60 | } 61 | 62 | // A size that preserves existing alignment restrictions. 63 | // Beware: can seriously increase size requirements. 64 | enum { HeaderSize = lcm<(int) SuperHeap::Alignment, sizeof(Add)>::value }; 65 | 66 | }; 67 | 68 | } 69 | #endif 70 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/objectrep/all.h: -------------------------------------------------------------------------------- 1 | #include "addheap.h" 2 | #include "coalesceableheap.h" 3 | #include "sizeheap.h" 4 | #include "sizeownerheap.h" 5 | 6 | 7 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/objectrep/sizeownerheap.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_SIZEOWNERHEAP_H_ 28 | #define HL_SIZEOWNERHEAP_H_ 29 | 30 | #include 31 | 32 | #include "addheap.h" 33 | 34 | /** 35 | * @class SizeOwnerHeap 36 | * @brief Adds object size and owner heap information. 37 | */ 38 | 39 | namespace HL { 40 | 41 | template 42 | class SizeOwner { 43 | public: 44 | union { 45 | struct { 46 | size_t size; 47 | Heap * owner; 48 | } s; 49 | double dummy; 50 | }; 51 | }; 52 | 53 | template 54 | class SizeOwnerHeap : public AddHeap, Super> { 55 | private: 56 | 57 | typedef AddHeap, Super> SuperHeap; 58 | 59 | public: 60 | 61 | inline void * malloc (size_t sz) { 62 | void * ptr = SuperHeap::malloc (sz); 63 | // Store the requested size. 64 | SizeOwner * so = (SizeOwner *) ptr; 65 | so->s.size = sz; 66 | so->s.owner = this; 67 | // Store the owner. 68 | return (void *) (so + 1); 69 | } 70 | 71 | inline void free (void * ptr) { 72 | void * origPtr = (void *) ((SizeOwner *) ptr - 1); 73 | SuperHeap::free (origPtr); 74 | } 75 | 76 | static inline Super * owner (void * ptr) { 77 | SizeOwner * so = (SizeOwner *) ptr - 1; 78 | return so->s.owner; 79 | } 80 | 81 | static inline size_t size (void * ptr) { 82 | SizeOwner * so = (SizeOwner *) ptr - 1; 83 | return so->s.size; 84 | } 85 | }; 86 | 87 | } 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/special/all.h: -------------------------------------------------------------------------------- 1 | #include "bumpalloc.h" 2 | #include "nestedheap.h" 3 | #include "xallocheap.h" 4 | #include "zoneheap.h" 5 | 6 | // Deprecated: 7 | //#include "obstack.h" 8 | //#include "obstackheap.h" 9 | //#include "obstackreap.h" 10 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/special/bumpalloc.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_BUMPALLOC_H 28 | #define HL_BUMPALLOC_H 29 | 30 | /** 31 | * @class BumpAlloc 32 | * @brief Obtains memory in chunks and bumps a pointer through the chunks. 33 | * @author Emery Berger 34 | */ 35 | 36 | namespace HL { 37 | 38 | template 40 | class BumpAlloc : public Super { 41 | public: 42 | 43 | enum { Alignment = 1 }; 44 | 45 | BumpAlloc (void) 46 | : _bump (NULL), 47 | _remaining (0) 48 | {} 49 | 50 | inline void * malloc (size_t sz) { 51 | // If there's not enough space left to fulfill this request, get 52 | // another chunk. 53 | if (_remaining < sz) { 54 | refill(sz); 55 | } 56 | char * old = _bump; 57 | _bump += sz; 58 | _remaining -= sz; 59 | return old; 60 | } 61 | 62 | /// Free is disabled (we only bump, never reclaim). 63 | inline bool free (void *) { return false; } 64 | 65 | private: 66 | 67 | /// The bump pointer. 68 | char * _bump; 69 | 70 | /// How much space remains in the current chunk. 71 | size_t _remaining; 72 | 73 | // Get another chunk. 74 | void refill (size_t sz) { 75 | if (sz < ChunkSize) { 76 | sz = ChunkSize; 77 | } 78 | _bump = (char *) Super::malloc (sz); 79 | _remaining = sz; 80 | } 81 | 82 | }; 83 | 84 | } 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/threads/all.h: -------------------------------------------------------------------------------- 1 | #include "lockedheap.h" 2 | #include "phothreadheap.h" 3 | #include "threadheap.h" 4 | #include "threadspecificheap.h" 5 | #include "sizethreadheap.h" 6 | 7 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/threads/lockedheap.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_LOCKEDHEAP_H 28 | #define HL_LOCKEDHEAP_H 29 | 30 | #include "utility/guard.h" 31 | 32 | namespace HL { 33 | 34 | template 35 | class LockedHeap : public Super { 36 | public: 37 | 38 | enum { Alignment = Super::Alignment }; 39 | 40 | inline void * malloc (size_t sz) { 41 | Guard l (thelock); 42 | return Super::malloc (sz); 43 | } 44 | 45 | inline void free (void * ptr) { 46 | Guard l (thelock); 47 | Super::free (ptr); 48 | } 49 | 50 | inline size_t getSize (void * ptr) const { 51 | Guard l (thelock); 52 | return Super::getSize (ptr); 53 | } 54 | 55 | inline size_t getSize (void * ptr) { 56 | Guard l (thelock); 57 | return Super::getSize (ptr); 58 | } 59 | 60 | inline void lock (void) { 61 | thelock.lock(); 62 | } 63 | 64 | inline void unlock (void) { 65 | thelock.unlock(); 66 | } 67 | 68 | private: 69 | // char dummy[128]; // an effort to avoid false sharing. 70 | LockType thelock; 71 | }; 72 | 73 | } 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/threads/phothreadheap.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | #ifndef HL_PHOTHREADHEAP_H 4 | #define HL_PHOTHREADHEAP_H 5 | 6 | #include 7 | 8 | #include "threads/cpuinfo.h" 9 | 10 | using namespace HL; 11 | 12 | template 13 | class MarkThreadHeap : public SuperHeap { 14 | public: 15 | 16 | inline void * malloc (size_t sz) { 17 | int tid = CPUInfo::getThreadId() % NumHeaps; 18 | void * ptr = SuperHeap::malloc (sz); 19 | if (ptr != NULL) { 20 | SuperHeap::setHeap(ptr, tid); 21 | SuperHeap::setPrevHeap(SuperHeap::getNext(ptr), tid); 22 | } 23 | return ptr; 24 | } 25 | }; 26 | 27 | 28 | template 29 | class CheckThreadHeap : public SuperHeap { 30 | public: 31 | 32 | inline void * malloc (size_t sz) { 33 | void * ptr = SuperHeap::malloc (sz); 34 | if (ptr != NULL) { 35 | int tid = CPUInfo::getThreadId() % NumHeaps; 36 | tid; 37 | assert (SuperHeap::getHeap(ptr) == tid); 38 | } 39 | return ptr; 40 | } 41 | 42 | inline void free (void * ptr) { 43 | SuperHeap::free (ptr); 44 | } 45 | }; 46 | 47 | 48 | 49 | /* 50 | 51 | A PHOThreadHeap comprises NumHeaps "per-thread" heaps. 52 | 53 | To pick a per-thread heap, the current thread id is hashed (mod NumHeaps). 54 | 55 | malloc gets memory from its hashed per-thread heap. 56 | free returns memory to its originating heap. 57 | 58 | NB: We assume that the thread heaps are 'locked' as needed. */ 59 | 60 | 61 | template 62 | class PHOThreadHeap { // : public MarkThreadHeap { 63 | public: 64 | 65 | inline void * malloc (size_t sz) { 66 | int tid = CPUInfo::getThreadId() % NumHeaps; 67 | void * ptr = selectHeap(tid)->malloc (sz); 68 | return ptr; 69 | } 70 | 71 | inline void free (void * ptr) { 72 | int tid = SuperHeap::getHeap(ptr); 73 | selectHeap(tid)->free (ptr); 74 | } 75 | 76 | 77 | inline int remove (void * ptr); 78 | #if 0 79 | { 80 | int tid = SuperHeap::getHeap(ptr); 81 | selectHeap(tid)->remove (ptr); 82 | } 83 | #endif 84 | 85 | private: 86 | 87 | // Access the given heap within the buffer. 88 | MarkThreadHeap * selectHeap (int index) { 89 | assert (index >= 0); 90 | assert (index < NumHeaps); 91 | return &ptHeaps[index]; 92 | } 93 | 94 | MarkThreadHeap ptHeaps[NumHeaps]; 95 | 96 | }; 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/threads/sizethreadheap.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | #ifndef HL_SIZETHREADHEAP_H 4 | #define HL_SIZETHREADHEAP_H 5 | 6 | #include 7 | 8 | #include "threads/cpuinfo.h" 9 | 10 | namespace HL { 11 | 12 | template 13 | class SizeThreadHeap : public Super { 14 | public: 15 | 16 | inline void * malloc (size_t sz) { 17 | // Add room for a size field & a thread field. 18 | // Both of these must fit in a double. 19 | assert (sizeof(st) <= sizeof(double)); 20 | st * ptr = (st *) Super::malloc (sz + sizeof(double)); 21 | // Store the requested size. 22 | ptr->size = sz; 23 | assert (getOrigPtr(ptr + 1) == ptr); 24 | return (void *) (ptr + 1); 25 | } 26 | 27 | inline void free (void * ptr) { 28 | void * origPtr = (void *) getOrigPtr(ptr); 29 | Super::free (origPtr); 30 | } 31 | 32 | static inline size_t& size (void * ptr) { 33 | return getOrigPtr(ptr)->size; 34 | } 35 | 36 | static inline int& thread (void * ptr) { 37 | return getOrigPtr(ptr)->tid; 38 | } 39 | 40 | private: 41 | 42 | typedef struct _st { 43 | size_t size; 44 | int tid; 45 | } st; 46 | 47 | static inline st * getOrigPtr (void * ptr) { 48 | return (st *) ((double *) ptr - 1); 49 | } 50 | 51 | }; 52 | 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/top/all.h: -------------------------------------------------------------------------------- 1 | #include "mallocheap.h" 2 | #include "mmapheap.h" 3 | #include "sbrkheap.h" 4 | #include "staticheap.h" 5 | 6 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/top/mallocheap.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_MALLOCHEAP_H 28 | #define HL_MALLOCHEAP_H 29 | 30 | #include 31 | 32 | #if defined(__SVR4) 33 | extern "C" size_t malloc_usable_size (void *); 34 | #else 35 | extern "C" size_t malloc_usable_size (void *) throw (); 36 | #endif 37 | 38 | /** 39 | * @class MallocHeap 40 | * @brief A "source heap" that uses malloc and free. 41 | */ 42 | 43 | #include "wrappers/mallocinfo.h" 44 | 45 | 46 | namespace HL { 47 | 48 | class MallocHeap { 49 | public: 50 | 51 | enum { Alignment = MallocInfo::Alignment }; 52 | 53 | ~MallocHeap (void) {} 54 | 55 | inline void * malloc (size_t sz) { 56 | return ::malloc (sz); 57 | } 58 | 59 | 60 | inline void free (void * ptr) { 61 | ::free (ptr); 62 | } 63 | 64 | #if defined(_MSC_VER) 65 | inline size_t getSize (void * ptr) { 66 | return ::_msize (ptr); 67 | } 68 | #elif defined(__GNUC__) && !defined(__SVR4) 69 | inline size_t getSize (void * ptr) { 70 | return ::malloc_usable_size (ptr); 71 | } 72 | #elif defined(__APPLE__) 73 | inline size_t getSize (void * ptr) { 74 | return ::malloc_size (ptr); 75 | } 76 | #endif 77 | 78 | }; 79 | 80 | } 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/top/sbrkheap.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | #ifndef HL_SBRKHEAP_H 4 | #define HL_SBRKHEAP_H 5 | 6 | #ifdef WIN32 7 | 8 | // If we're using Windows, we'll need to link in sbrk.c, 9 | // a replacement for sbrk(). 10 | 11 | extern "C" void * sbrk (size_t sz); 12 | 13 | #endif 14 | 15 | /* 16 | * @class SbrkHeap 17 | * @brief A source heap that is a thin wrapper over sbrk. 18 | * 19 | * As it stands, memory cannot be returned to sbrk(). 20 | * This is not a significant limitation, since only memory 21 | * at the end of the break point can ever be returned anyway. 22 | */ 23 | 24 | namespace HL { 25 | 26 | class SbrkHeap { 27 | public: 28 | 29 | enum { Alignment = 16 }; 30 | 31 | SbrkHeap (void) 32 | { 33 | void * ptr = sbrk(0); 34 | while ((size_t) ptr % Alignment != 0) { 35 | ptr = sbrk(1); 36 | } 37 | } 38 | 39 | inline void * malloc (size_t sz) { 40 | if (sz == 0) { 41 | sz = Alignment; 42 | } else { 43 | while (sz % Alignment != 1) { 44 | sz++; 45 | } 46 | } 47 | return sbrk(sz); 48 | } 49 | inline void free (void *) { } 50 | }; 51 | 52 | } 53 | 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/top/staticheap.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | /* 28 | 29 | StaticHeap: manage a fixed range of memory. 30 | 31 | */ 32 | 33 | #ifndef HL_STATICHEAP_H 34 | #define HL_STATICHEAP_H 35 | 36 | namespace HL { 37 | 38 | template 39 | class StaticHeap { 40 | public: 41 | 42 | StaticHeap (void) 43 | : ptr (&buf[0]), 44 | remaining (MemorySize) 45 | {} 46 | 47 | enum { Alignment = 1 }; 48 | 49 | inline void * malloc (size_t sz) { 50 | if (remaining < sz) { 51 | return NULL; 52 | } 53 | void * p = ptr; 54 | ptr += sz; 55 | remaining -= sz; 56 | return p; 57 | } 58 | 59 | void free (void *) {} 60 | int remove (void *) { return 0; } 61 | 62 | int isValid (void * ptr) { 63 | return (((size_t) ptr >= (size_t) buf) && 64 | ((size_t) ptr < (size_t) buf)); 65 | } 66 | 67 | private: 68 | 69 | // Disable copying and assignment. 70 | StaticHeap (const StaticHeap& treap); 71 | StaticHeap& operator= (const StaticHeap& treap); 72 | 73 | char buf[MemorySize]; 74 | char * ptr; 75 | size_t remaining; 76 | }; 77 | 78 | } 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/utility/all.h: -------------------------------------------------------------------------------- 1 | #include "exceptionheap.h" 2 | #include "nullheap.h" 3 | #include "perclassheap.h" 4 | #include "slopheap.h" 5 | #include "uniqueheap.h" 6 | #include "localmallocheap.h" 7 | #include "oneheap.h" 8 | #include "profileheap.h" 9 | #include "traceheap.h" 10 | 11 | 12 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/utility/exceptionheap.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_EXCEPTIONHEAP_H 28 | #define HL_EXCEPTIONHEAP_H 29 | 30 | #include 31 | 32 | //class std::bad_alloc; 33 | 34 | namespace HL { 35 | 36 | template 37 | class ExceptionHeap : public Super { 38 | public: 39 | inline void * malloc (size_t sz) throw (std::bad_alloc) { 40 | void * ptr = Super::malloc (sz); 41 | if (ptr == NULL) { 42 | throw new std::bad_alloc; 43 | } 44 | return ptr; 45 | } 46 | }; 47 | 48 | 49 | template 50 | class CatchExceptionHeap : public Super { 51 | public: 52 | inline void * malloc (size_t sz) { 53 | void * ptr; 54 | try { 55 | ptr = Super::malloc (sz); 56 | } catch (std::bad_alloc) { 57 | ptr = NULL; 58 | } 59 | return ptr; 60 | } 61 | }; 62 | 63 | } 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/utility/nullheap.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_NULLHEAP_H 28 | #define HL_NULLHEAP_H 29 | 30 | #include 31 | 32 | /** 33 | * @class NullHeap 34 | * @brief A source heap that does nothing. 35 | */ 36 | 37 | namespace HL { 38 | 39 | template 40 | class NullHeap : public SuperHeap { 41 | public: 42 | inline void * malloc (size_t) const { return 0; } 43 | inline void free (void *) const {} 44 | inline int remove (void *) const { return 0; } 45 | inline void clear (void) const {} 46 | inline size_t getSize (void *) const { return 0; } 47 | }; 48 | 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/utility/old/oneheap.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2003 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_ONEHEAP_H 28 | #define HL_ONEHEAP_H 29 | 30 | // 31 | // Wrap a single instance of a heap. 32 | // 33 | 34 | namespace HL { 35 | 36 | template 37 | class OneHeap { 38 | public: 39 | OneHeap (void) 40 | : theHeap (getHeap()) 41 | {} 42 | 43 | inline void * malloc (const size_t sz) { 44 | return theHeap->malloc (sz); 45 | } 46 | inline void free (void * ptr) { 47 | theHeap->free (ptr); 48 | } 49 | inline int remove (void * ptr) { 50 | return theHeap->remove (ptr); 51 | } 52 | inline void clear (void) { 53 | theHeap->clear(); 54 | } 55 | inline size_t getSize (void * ptr) { 56 | return theHeap->getSize (ptr); 57 | } 58 | 59 | enum { Alignment = SuperHeap::Alignment }; 60 | 61 | private: 62 | 63 | SuperHeap * theHeap; 64 | 65 | inline static SuperHeap * getHeap (void) { 66 | static SuperHeap theHeap; 67 | return &theHeap; 68 | } 69 | }; 70 | 71 | } 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/utility/oneheap.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef HL_ONEHEAP_H 4 | #define HL_ONEHEAP_H 5 | 6 | #include "utility/singleton.h" 7 | 8 | namespace HL { 9 | 10 | template 11 | class OneHeap : public singleton { 12 | public: 13 | 14 | enum { Alignment = TheHeap::Alignment }; 15 | 16 | static inline void * malloc (size_t sz) { 17 | return singleton::getInstance().malloc (sz); 18 | } 19 | 20 | static inline bool free (void * ptr) { 21 | return singleton::getInstance().free (ptr); 22 | } 23 | 24 | static inline size_t getSize (void * ptr) { 25 | return singleton::getInstance().getSize (ptr); 26 | } 27 | }; 28 | 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/utility/perclassheap.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_PERCLASSHEAP_H 28 | #define HL_PERCLASSHEAP_H 29 | 30 | #include 31 | 32 | /** 33 | * @class PerClassHeap 34 | * @brief Enable the use of one heap for all class memory allocation. 35 | * 36 | * This class contains one instance of the SuperHeap argument. The 37 | * example below shows how to make a subclass of Foo that uses a 38 | * FreelistHeap to manage its memory, overloading operators new and 39 | * delete. 40 | * 41 | * 42 | * class NewFoo : public Foo, PerClassHeap > {}; 43 | * 44 | */ 45 | 46 | namespace HL { 47 | 48 | template 49 | class PerClassHeap { 50 | public: 51 | inline void * operator new (size_t sz) { 52 | return getHeap()->malloc (sz); 53 | } 54 | inline void operator delete (void * ptr) { 55 | getHeap()->free (ptr); 56 | } 57 | inline void * operator new[] (size_t sz) { 58 | return getHeap()->malloc (sz); 59 | } 60 | inline void operator delete[] (void * ptr) { 61 | getHeap()->free (ptr); 62 | } 63 | // For some reason, g++ needs placement new to be overridden 64 | // as well, at least in conjunction with use of the STL. 65 | // Otherwise, this should be superfluous. 66 | inline void * operator new (size_t, void * p) { return p; } 67 | inline void * operator new[] (size_t, void * p) { return p; } 68 | 69 | private: 70 | inline static SuperHeap * getHeap (void) { 71 | static SuperHeap theHeap; 72 | return &theHeap; 73 | } 74 | }; 75 | 76 | } 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /Heap-Layers/heaps/utility/profileheap.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_PROFILEHEAP_H 28 | #define HL_PROFILEHEAP_H 29 | 30 | #include 31 | 32 | // Maintain & print memory usage info. 33 | // Requires a superheap with the size() method (e.g., SizeHeap). 34 | 35 | namespace HL { 36 | 37 | template 38 | class ProfileHeap : public SuperHeap { 39 | public: 40 | 41 | ProfileHeap (void) 42 | : memRequested (0), 43 | maxMemRequested (0) 44 | { 45 | } 46 | 47 | ~ProfileHeap (void) 48 | { 49 | if (maxMemRequested > 0) { 50 | stats(); 51 | } 52 | } 53 | 54 | inline void * malloc (size_t sz) { 55 | void * ptr = SuperHeap::malloc (sz); 56 | // Notice that we use the size reported by the allocator 57 | // for the object rather than the requested size. 58 | memRequested += SuperHeap::getSize(ptr); 59 | if (memRequested > maxMemRequested) { 60 | maxMemRequested = memRequested; 61 | } 62 | return ptr; 63 | } 64 | 65 | inline void free (void * ptr) { 66 | memRequested -= SuperHeap::getSize (ptr); 67 | SuperHeap::free (ptr); 68 | } 69 | 70 | private: 71 | void stats (void) { 72 | printf ("Heap: %d\n", HeapNumber); 73 | printf ("Max memory requested = %d\n", maxMemRequested); 74 | printf ("Memory still in use = %d\n", memRequested); 75 | } 76 | 77 | unsigned long memRequested; 78 | unsigned long maxMemRequested; 79 | }; 80 | 81 | } 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /Heap-Layers/locks/all.h: -------------------------------------------------------------------------------- 1 | #include "maclock.h" 2 | #include "posixlock.h" 3 | #include "recursivelock.h" 4 | #include "spinlock.h" 5 | #include "winlock.h" 6 | 7 | -------------------------------------------------------------------------------- /Heap-Layers/locks/maclock.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_MACLOCK_H 28 | #define HL_MACLOCK_H 29 | 30 | #if defined(__APPLE__) 31 | 32 | #include 33 | 34 | /** 35 | * @class MacLockType 36 | * @brief Locking using OS X spin locks. 37 | */ 38 | 39 | namespace HL { 40 | 41 | class MacLockType { 42 | public: 43 | 44 | MacLockType (void) 45 | : mutex (0) 46 | {} 47 | 48 | ~MacLockType (void) 49 | { 50 | mutex = 0; 51 | } 52 | 53 | inline void lock (void) { 54 | OSSpinLockLock (&mutex); 55 | } 56 | 57 | inline void unlock (void) { 58 | OSSpinLockUnlock (&mutex); 59 | } 60 | 61 | private: 62 | 63 | OSSpinLock mutex; 64 | 65 | }; 66 | 67 | } 68 | 69 | #endif 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /Heap-Layers/locks/posixlock.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_POSIXLOCK_H 28 | #define HL_POSIXLOCK_H 29 | 30 | #if !defined(_WIN32) 31 | 32 | #include 33 | 34 | /** 35 | * @class PosixLockType 36 | * @brief Locking using POSIX mutex objects. 37 | */ 38 | 39 | namespace HL { 40 | 41 | class PosixLockType { 42 | public: 43 | 44 | PosixLockType (void) 45 | { 46 | int r = pthread_mutex_init (&mutex, NULL); 47 | if (r) { 48 | throw 0; 49 | } 50 | } 51 | 52 | ~PosixLockType (void) 53 | { 54 | pthread_mutex_destroy (&mutex); 55 | } 56 | 57 | void lock (void) { 58 | pthread_mutex_lock (&mutex); 59 | } 60 | 61 | void unlock (void) { 62 | pthread_mutex_unlock (&mutex); 63 | } 64 | 65 | private: 66 | union { 67 | pthread_mutex_t mutex; 68 | double _dummy[sizeof(pthread_mutex_t)/sizeof(double) + 1]; 69 | }; 70 | }; 71 | 72 | } 73 | 74 | #endif 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /Heap-Layers/locks/recursivelock.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_RECURSIVELOCK_H 28 | #define HL_RECURSIVELOCK_H 29 | 30 | #include "threads/cpuinfo.h" 31 | 32 | /** 33 | * @class RecursiveLockType 34 | * @brief Implements a recursive lock using some base lock representation. 35 | * @param BaseLock The base lock representation. 36 | */ 37 | 38 | namespace HL { 39 | 40 | template 41 | class RecursiveLockType : public BaseLock { 42 | public: 43 | 44 | inline RecursiveLockType (void) 45 | : _tid (-1), 46 | _recursiveDepth (0) 47 | {} 48 | 49 | inline void lock() { 50 | int currthread = CPUInfo::getThreadId(); 51 | if (_tid == currthread) { 52 | _recursiveDepth++; 53 | } else { 54 | BaseLock::lock(); 55 | _tid = currthread; 56 | _recursiveDepth++; 57 | } 58 | } 59 | 60 | inline void unlock (void) { 61 | int currthread = CPUInfo::getThreadId(); 62 | if (_tid == currthread) { 63 | _recursiveDepth--; 64 | if (_recursiveDepth == 0) { 65 | _tid = -1; 66 | BaseLock::unlock(); 67 | } 68 | } else { 69 | // We tried to unlock it but we didn't lock it! 70 | // This should never happen. 71 | assert (0); 72 | abort(); 73 | } 74 | } 75 | 76 | private: 77 | int _tid; /// The lock owner's thread id. -1 if unlocked. 78 | int _recursiveDepth; /// The recursion depth of the lock. 79 | }; 80 | 81 | } 82 | 83 | 84 | 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /Heap-Layers/locks/winlock.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_WINLOCK_H 28 | #define HL_WINLOCK_H 29 | 30 | #if defined(_WIN32) 31 | 32 | #include 33 | #include 34 | 35 | /** 36 | * @class WinLockType 37 | * @brief Locking using Win32 mutexes. 38 | * 39 | * Note that this lock type detects whether we are running on a 40 | * multiprocessor. If not, then we do not use atomic operations. 41 | */ 42 | 43 | namespace HL { 44 | 45 | class WinLockType { 46 | public: 47 | 48 | WinLockType (void) 49 | : mutex (0) 50 | {} 51 | 52 | ~WinLockType (void) 53 | { 54 | mutex = 0; 55 | } 56 | 57 | inline void lock (void) { 58 | int spinCount = 0; 59 | while (InterlockedExchange ((long *) &mutex, 1) != 0) { 60 | while (mutex != 0) { 61 | YieldProcessor(); 62 | } 63 | } 64 | } 65 | 66 | inline void unlock (void) { 67 | mutex = 0; 68 | // InterlockedExchange (&mutex, 0); 69 | } 70 | 71 | private: 72 | unsigned int mutex; 73 | bool onMultiprocessor (void) { 74 | SYSTEM_INFO infoReturn[1]; 75 | GetSystemInfo (infoReturn); 76 | if (infoReturn->dwNumberOfProcessors == 1) { 77 | return FALSE; 78 | } else { 79 | return TRUE; 80 | } 81 | } 82 | }; 83 | 84 | } 85 | 86 | #endif 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /Heap-Layers/threads/all.h: -------------------------------------------------------------------------------- 1 | #include "cpuinfo.h" 2 | #include "fred.h" 3 | -------------------------------------------------------------------------------- /Heap-Layers/threads/fred.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef HL_FRED_H 4 | #define HL_FRED_H 5 | 6 | /// A thread-wrapper of childlike simplicity :). 7 | 8 | #if defined(_WIN32) 9 | 10 | #include 11 | #include 12 | 13 | #elif defined(__SVR4) 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #else 20 | 21 | #include 22 | #include 23 | 24 | #endif 25 | 26 | namespace HL { 27 | 28 | extern "C" typedef void * (*ThreadFunctionType) (void *); 29 | 30 | class Fred { 31 | public: 32 | 33 | Fred (void) { 34 | #if !defined(_WIN32) 35 | pthread_attr_init (&attr); 36 | #endif 37 | } 38 | 39 | ~Fred (void) { 40 | #if !defined(_WIN32) 41 | pthread_attr_destroy (&attr); 42 | #endif 43 | } 44 | 45 | void create (ThreadFunctionType function, void * arg) { 46 | #if defined(_WIN32) 47 | t = CreateThread (0, 0, (LPTHREAD_START_ROUTINE) *function, (LPVOID) arg, 0, 0); 48 | #else 49 | pthread_create (&t, &attr, function, arg); 50 | #endif 51 | } 52 | 53 | void join (void) { 54 | #if defined(_WIN32) 55 | WaitForSingleObject (t, INFINITE); 56 | #else 57 | pthread_join (t, NULL); 58 | #endif 59 | } 60 | 61 | static void yield (void) { 62 | #if defined(_WIN32) 63 | Sleep (0); 64 | #elif defined(__SVR4) 65 | thr_yield(); 66 | #else 67 | sched_yield(); 68 | #endif 69 | } 70 | 71 | 72 | static void setConcurrency (int n) { 73 | #if defined(_WIN32) 74 | #elif defined(__SVR4) 75 | thr_setconcurrency (n); 76 | #else 77 | pthread_setconcurrency (n); 78 | #endif 79 | } 80 | 81 | 82 | private: 83 | 84 | Fred (const Fred&); 85 | Fred& operator=(const Fred&); 86 | 87 | #if defined(_WIN32) 88 | typedef HANDLE FredType; 89 | #else 90 | typedef pthread_t FredType; 91 | pthread_attr_t attr; 92 | #endif 93 | 94 | FredType t; 95 | }; 96 | 97 | } 98 | 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /Heap-Layers/utility/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/Heap-Layers/utility/a.out -------------------------------------------------------------------------------- /Heap-Layers/utility/align.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef HL_ALIGN_H 4 | #define HL_ALIGN_H 5 | 6 | #include 7 | 8 | #include "sassert.h" 9 | 10 | namespace HL { 11 | 12 | /// @name align 13 | /// @brief Rounds up a value to the next multiple of v. 14 | /// @note Argument must be a power of two. 15 | template 16 | inline size_t align (size_t v) { 17 | sassert<((Alignment & (Alignment-1)) == 0)> isPowerOfTwo; 18 | return ((v + (Alignment-1)) & ~(Alignment-1)); 19 | } 20 | 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /Heap-Layers/utility/all.h: -------------------------------------------------------------------------------- 1 | #include "align.h" 2 | #include "bins.h" 3 | #include "bins16k.h" 4 | #include "bins4k.h" 5 | #include "bins64k.h" 6 | #include "bins8k.h" 7 | #include "dllist.h" 8 | #include "dynarray.h" 9 | #include "freesllist.h" 10 | #include "hash.h" 11 | #include "gcd.h" 12 | #include "guard.h" 13 | #include "istrue.h" 14 | #include "lcm.h" 15 | #include "myhashmap.h" 16 | #include "sassert.h" 17 | #include "sllist.h" 18 | #include "timer.h" 19 | 20 | -------------------------------------------------------------------------------- /Heap-Layers/utility/bins.h: -------------------------------------------------------------------------------- 1 | #ifndef HL_BINS_H 2 | #define HL_BINS_H 3 | 4 | namespace HL { 5 | 6 | template 7 | class bins; 8 | 9 | } 10 | 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /Heap-Layers/utility/bins4k.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #if !defined(_BINS4K_H_) 4 | #define _BINS4K_H_ 5 | 6 | #include "bins.h" 7 | #include "sassert.h" 8 | 9 | namespace HL { 10 | 11 | template 12 | class bins { 13 | 14 | public: 15 | bins (void) {} 16 | 17 | enum { NUM_BINS = 33 }; 18 | enum { BIG_OBJECT = 4096 - sizeof(Header) }; 19 | 20 | static const size_t _bins[NUM_BINS]; 21 | 22 | static inline int getSizeClass (size_t sz) { 23 | assert (sz <= BIG_OBJECT); 24 | if (sz < 8) { 25 | return 0; 26 | } else if (sz <= 128) { 27 | return ((sz + 7) >> 3) - 1; 28 | } else { 29 | return slowLookupSizeClass (sz); 30 | } 31 | } 32 | 33 | static inline size_t getClassSize (const int i) { 34 | assert (i >= 0); 35 | assert (i < NUM_BINS); 36 | return _bins[i]; 37 | } 38 | 39 | private: 40 | 41 | static int slowLookupSizeClass (const size_t sz) { 42 | // Find the size class for a given object size 43 | // (the smallest i such that _bins[i] >= sz). 44 | int sizeclass = 0; 45 | while (_bins[sizeclass] < sz) 46 | { 47 | sizeclass++; 48 | assert (sizeclass < NUM_BINS); 49 | } 50 | return sizeclass; 51 | } 52 | 53 | sassert<(BIG_OBJECT > 0)> verifyHeaderSize; 54 | 55 | }; 56 | } 57 | 58 | template 59 | const size_t HL::bins::_bins[NUM_BINS] = {8UL, 16UL, 24UL, 32UL, 40UL, 48UL, 56UL, 64UL, 72UL, 80UL, 88UL, 96UL, 104UL, 112UL, 120UL, 128UL, 152UL, 176UL, 208UL, 248UL, 296UL, 352UL, 416UL, 496UL, 592UL, 704UL, 856UL, 1024UL, 1224UL, 1712UL, 2048UL, 3416UL, 4096UL - sizeof(Header)}; 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /Heap-Layers/utility/freesllist.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef _FREESLLIST_H_ 4 | #define _FREESLLIST_H_ 5 | 6 | #include 7 | 8 | /** 9 | * @class FreeSLList 10 | * @brief A "memory neutral" singly-linked list, 11 | * 12 | * Uses the free space in objects to store 13 | * the pointers. 14 | */ 15 | 16 | 17 | class FreeSLList { 18 | public: 19 | 20 | inline void clear (void) { 21 | head.next = NULL; 22 | } 23 | 24 | class Entry; 25 | 26 | /// Get the head of the list. 27 | inline Entry * get (void) { 28 | const Entry * e = head.next; 29 | if (e == NULL) { 30 | return NULL; 31 | } 32 | head.next = e->next; 33 | return const_cast(e); 34 | } 35 | 36 | inline Entry * remove (void) { 37 | const Entry * e = head.next; 38 | if (e == NULL) { 39 | return NULL; 40 | } 41 | head.next = e->next; 42 | return const_cast(e); 43 | } 44 | 45 | inline void insert (void * e) { 46 | Entry * entry = reinterpret_cast(e); 47 | entry->next = head.next; 48 | head.next = entry; 49 | } 50 | 51 | class Entry { 52 | public: 53 | Entry (void) 54 | : next (NULL) 55 | {} 56 | Entry * next; 57 | private: 58 | Entry (const Entry&); 59 | Entry& operator=(const Entry&); 60 | }; 61 | 62 | private: 63 | Entry head; 64 | }; 65 | 66 | 67 | #endif 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Heap-Layers/utility/gcd.h: -------------------------------------------------------------------------------- 1 | #ifndef GCD_H 2 | #define GCD_H 3 | 4 | template struct gcd 5 | { 6 | static const int value = gcd::value; 7 | }; 8 | 9 | template struct gcd 10 | { 11 | static const int value = a; 12 | }; 13 | 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /Heap-Layers/utility/guard.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_GUARD_H 28 | #define HL_GUARD_H 29 | 30 | namespace HL { 31 | 32 | template 33 | class Guard { 34 | public: 35 | inline Guard (LockType& l) 36 | : _lock (l) 37 | { 38 | _lock.lock(); 39 | } 40 | 41 | inline ~Guard (void) { 42 | _lock.unlock(); 43 | } 44 | private: 45 | LockType& _lock; 46 | }; 47 | 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /Heap-Layers/utility/hash.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef HL_HASH_H 4 | #define HL_HASH_H 5 | 6 | #include 7 | #include 8 | 9 | namespace HL { 10 | 11 | template 12 | class Hash { 13 | public: 14 | static size_t hash (Key k); 15 | }; 16 | 17 | template <> 18 | class Hash { 19 | public: 20 | static inline size_t hash (void * v) { 21 | return (size_t) v; 22 | } 23 | }; 24 | 25 | template <> 26 | class Hash { 27 | public: 28 | static inline size_t hash (void * v) { 29 | return (size_t) ((size_t) v); 30 | } 31 | }; 32 | 33 | template <> 34 | class Hash { 35 | public: 36 | static inline size_t hash (int v) { 37 | return (size_t) v; 38 | } 39 | }; 40 | 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Heap-Layers/utility/istrue.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef HL_ISTRUE_H 4 | #define HL_ISTRUE_H 5 | 6 | /* 7 | 8 | Heap Layers: An Extensible Memory Allocation Infrastructure 9 | 10 | Copyright (C) 2000-2012 by Emery Berger 11 | http://www.cs.umass.edu/~emery 12 | emery@cs.umass.edu 13 | 14 | This program is free software; you can redistribute it and/or modify 15 | it under the terms of the GNU General Public License as published by 16 | the Free Software Foundation; either version 2 of the License, or 17 | (at your option) any later version. 18 | 19 | This program is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | GNU General Public License for more details. 23 | 24 | You should have received a copy of the GNU General Public License 25 | along with this program; if not, write to the Free Software 26 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 27 | 28 | */ 29 | 30 | namespace HL { 31 | 32 | template 33 | class IsTrue; 34 | 35 | template<> 36 | class IsTrue { 37 | public: 38 | enum { value = true }; 39 | }; 40 | 41 | template<> 42 | class IsTrue { 43 | public: 44 | enum { value = false }; 45 | }; 46 | 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /Heap-Layers/utility/lcm.h: -------------------------------------------------------------------------------- 1 | #ifndef LCM_H 2 | #define LCM_H 3 | 4 | #include "gcd.h" 5 | 6 | template struct lcm 7 | { 8 | static const int value = (a * b) / (gcd::value); 9 | }; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /Heap-Layers/utility/sassert.h: -------------------------------------------------------------------------------- 1 | #ifndef HL_SASSERT_H 2 | #define HL_SASSERT_H 3 | 4 | /** 5 | * @class sassert 6 | * @brief Implements compile-time assertion checking. 7 | * @author Emery Berger 8 | * 9 | * @code 10 | * sassert<(1+1 == 2)> CheckOnePlusOneIsTwo; 11 | * @endcode 12 | * 13 | * This code is part of the Hoard distribution and is governed by its license. 14 | * 15 | * 16 | */ 17 | 18 | namespace HL { 19 | 20 | template 21 | class sassert; 22 | 23 | template<> class sassert { 24 | public: 25 | enum { VALUE = true }; 26 | }; 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Heap-Layers/utility/singleton.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef HL_SINGLETON_H 4 | #define HL_SINGLETON_H 5 | 6 | #include 7 | 8 | namespace HL { 9 | 10 | template 11 | class singleton { 12 | public: 13 | 14 | static inline C& getInstance() { 15 | static char buf[sizeof(C)]; 16 | static C * theSingleton = new (buf) C; 17 | return *theSingleton; 18 | } 19 | 20 | }; 21 | 22 | } 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /Heap-Layers/utility/testalign.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | #include "align.h" 6 | 7 | int 8 | main(int argc, char * argv[]) 9 | { 10 | for (int i = 0; i < 100; i++) { 11 | cout << i << "\t" << HL::align<4>(i) << endl; 12 | } 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /Heap-Layers/wrappers/all.h: -------------------------------------------------------------------------------- 1 | #include "ansiwrapper.h" 2 | #include "macinterpose.h" 3 | #include "mmapwrapper.h" 4 | #include "stlallocator.h" 5 | -------------------------------------------------------------------------------- /Heap-Layers/wrappers/arch-specific/sparc-interchange.il: -------------------------------------------------------------------------------- 1 | .inline MyInterlockedExchange,8 2 | 3 | mov %o0,%o2 4 | mov %o1,%o0 5 | swap [%o2],%o0 6 | 7 | .end 8 | -------------------------------------------------------------------------------- /Heap-Layers/wrappers/arch-specific/x86-interchange.il: -------------------------------------------------------------------------------- 1 | .inline MyInterlockedExchange,0 2 | 3 | movl (%esp),%ecx 4 | movl 4(%esp),%eax 5 | lock 6 | xchgl %eax,(%ecx) 7 | 8 | .end 9 | -------------------------------------------------------------------------------- /Heap-Layers/wrappers/arch-specific/x86_64-interchange.il: -------------------------------------------------------------------------------- 1 | .inline MyInterlockedExchange,0 2 | 3 | movq %rsi,%rax 4 | lock 5 | xchgq %rax,(%rdi) 6 | 7 | .end 8 | -------------------------------------------------------------------------------- /Heap-Layers/wrappers/macinterpose.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef HL_MACINTERPOSE_H 4 | #define HL_MACINTERPOSE_H 5 | 6 | // The interposition data structure (just pairs of function pointers), 7 | // used an interposition table like the following: 8 | // 9 | 10 | typedef struct interpose_s { 11 | void *new_func; 12 | void *orig_func; 13 | } interpose_t; 14 | 15 | #define MAC_INTERPOSE(newf,oldf) __attribute__((used)) \ 16 | static const interpose_t macinterpose##newf##oldf \ 17 | __attribute__ ((section("__DATA, __interpose"))) = \ 18 | { (void *) newf, (void *) oldf } 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /Heap-Layers/wrappers/mallocinfo.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2012 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #ifndef HL_MALLOCINFO_H 28 | #define HL_MALLOCINFO_H 29 | 30 | #include 31 | 32 | namespace HL { 33 | 34 | class MallocInfo { 35 | public: 36 | // Prevent integer overflows by restricting allocation size (usually 2GB). 37 | enum { MaxSize = UINT_MAX / 2 }; 38 | 39 | #if defined(__LP64__) || defined(_LP64) || defined(__APPLE__) || defined(_WIN64) || defined(__x86_64__) 40 | enum { MinSize = 16 }; 41 | enum { Alignment = 16 }; 42 | #else 43 | enum { MinSize = sizeof(double) }; 44 | enum { Alignment = sizeof(double) }; 45 | #endif 46 | }; 47 | 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | __if downloading from GitHub, make sure to use `--recursive`, as in:__ 2 | `git clone --recursive https://github.com/emeryberger/Malloc-Implementations` 3 | 4 | A collection of memory allocator implementations 5 | ------------------------------------------------ 6 | 7 | Curated by [Emery Berger](http://www.cs.umass.edu/~emery) 8 | 9 | 10 | -------------------------------------------------------------------------------- /allocators/CAMA/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc -Wall -W -g -std=c99 -DNDEBUG -O3 -fPIC 2 | CXX = g++ -Wall -W -g -DNDEBUG -O3 -fPIC 3 | 4 | libcama.so: libcama.cpp camarea.o 5 | $(CXX) -IHeap-Layers -shared libcama.cpp Heap-Layers/wrappers/gnuwrapper.cpp camarea.o -o libcama.so -lpthread -ldl 6 | 7 | #cama-driver: cama-driver.cpp camarea.o 8 | # $(CXX) cama-driver.cpp camarea.o -o cama-driver 9 | 10 | camarea.o: camarea.h camarea2.c 11 | $(CC) -c camarea2.c -o camarea.o 12 | 13 | .PHONY: clean 14 | 15 | clean: 16 | rm -f cama-driver camarea.o 17 | -------------------------------------------------------------------------------- /allocators/CAMA/bitops.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Cache-Aware Memory Allocator (CAMA) with Area Blocks 3 | * Version 1.0 4 | * 5 | * Authors: 6 | * Peter Backes (rtc@cs.uni-saarland.de) 7 | * Joerg Herter (jherter@cs.uni-saarland.de) 8 | * Christoph Mallon (mallon@cs.uni-saarland.de) 9 | * 10 | ******************************************************************************/ 11 | 12 | #ifndef BITOPS_H 13 | #define BITOPS_H 14 | 15 | #ifdef __linux__ 16 | # ifndef _GNU_SOURCE 17 | # define _GNU_SOURCE 1 18 | # endif 19 | # include 20 | #else 21 | # include 22 | #endif 23 | 24 | #include 25 | 26 | #define BIT_MASK(nr) (1UL << ((nr) % LONG_BIT)) 27 | #define BIT_WORD(nr) ((nr) / LONG_BIT) 28 | 29 | #ifndef LONG_BIT 30 | #define LONG_BIT (CHAR_BIT * sizeof (long)) 31 | #endif 32 | 33 | static inline unsigned long find_next_bit(const unsigned long *addr, 34 | unsigned long const size, unsigned long offset) 35 | { 36 | const unsigned long *p = addr + BIT_WORD(offset); 37 | unsigned long result = offset & ~(LONG_BIT-1), tmp; 38 | 39 | unsigned long count = (size - result) / LONG_BIT; 40 | unsigned long rest = (size - result) % LONG_BIT; 41 | 42 | offset %= LONG_BIT; 43 | if (offset) { 44 | tmp = *p++; 45 | tmp &= ~0UL << offset; 46 | if (count == 0) 47 | goto tailing_bits; 48 | if (tmp) 49 | goto found; 50 | count -= 1; 51 | result += LONG_BIT; 52 | } 53 | while (count != 0) { 54 | if ((tmp = *p++)) 55 | goto found; 56 | 57 | count -= 1; 58 | result += LONG_BIT; 59 | } 60 | if (rest == 0) 61 | return result; 62 | 63 | tmp = *p; 64 | 65 | tailing_bits: 66 | tmp &= ~0UL >> (LONG_BIT - rest); 67 | if (tmp == 0) 68 | return size; 69 | found: 70 | return result + ffsl(tmp) - 1; 71 | } 72 | 73 | 74 | static inline unsigned long set_bit(int nr, unsigned long *addr) 75 | { 76 | return addr[BIT_WORD(nr)] |= BIT_MASK(nr); 77 | } 78 | 79 | static inline unsigned long clear_bit(int nr, unsigned long *addr) 80 | { 81 | return addr[BIT_WORD(nr)] &= ~BIT_MASK(nr); 82 | } 83 | 84 | static inline int test_bit(int nr, const unsigned long *addr) 85 | { 86 | return 1UL & addr[BIT_WORD(nr)] >> (nr & (LONG_BIT-1)); 87 | } 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /allocators/CAMA/cama-driver.cpp: -------------------------------------------------------------------------------- 1 | /// @author Emery Berger 2 | 3 | #include 4 | using namespace std; 5 | 6 | #include 7 | 8 | extern "C" { 9 | #include "camarea.h" 10 | } 11 | 12 | int 13 | main() 14 | { 15 | cainit(); 16 | for (int i = 0; i < 100; i++) { 17 | for (int j = 0; j < 100; j++) { 18 | size_t sz = 16 * (i+1); 19 | void * ptr = camalloc (sz, 1); 20 | memset (ptr, 0, sz); 21 | cout << "size = " << camsize(ptr) << endl; 22 | if (ptr != NULL) { 23 | cafree (ptr); 24 | } 25 | } 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /allocators/CAMA/camarea.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Cache-Aware Memory Allocator (CAMA) with Area Blocks 3 | * Version 1.0 4 | * 5 | * Authors: 6 | * Christoph Mallon (mallon@cs.uni-saarland.de) 7 | * Joerg Herter (jherter@cs.uni-saarland.de) 8 | * 9 | ******************************************************************************/ 10 | 11 | #ifndef _CAMAREA_H 12 | #define _CAMAREA_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include 19 | 20 | /* 21 | * Initializes the allocator. 22 | * A program using CAMAREA needs to call this method once before using 23 | * camalloc(...) and cafree(...). 24 | */ 25 | void cainit(void); 26 | /* 27 | * Returns a pointer to a memory block of at least size bytes where 28 | * the first byte is mapped to cache set set; or null if the allocator 29 | * was unable to satisfy the request. 30 | */ 31 | void* camalloc(size_t size, unsigned set); 32 | /* 33 | * Deallocates, i.e. marks as free, the memory block pointed to by ptr. 34 | */ 35 | void cafree(void* ptr); 36 | 37 | /* EDB: Added. */ 38 | size_t camsize(void* ptr); 39 | 40 | 41 | /* 42 | * Cache-set relational allocations add-on: 43 | */ 44 | enum alloc_relation_t { 45 | ALLOC_DIFFERENT_SET, 46 | ALLOC_SAME_SET 47 | }; 48 | /* Allocate size bytes of memory, which has set relation rel to the null-pointer 49 | * terminated list of pointers. 50 | * For ALLOC_DIFFERENT_SET at least one set must not be excluded. 51 | * For ALLOC_SAME_SET at least one pointer must be given and all pointers must 52 | * point to the same set. */ 53 | void* carelmalloc(size_t size, enum alloc_relation_t rel, ...); 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /allocators/TLSF/TLSF-2.4.6/COPYING: -------------------------------------------------------------------------------- 1 | LICENSE INFORMATION 2 | 3 | TLSF is released as LGPL and GPL. A copy of both licences can be found in this 4 | directoy. For the GPL licence, the following exception applies. 5 | 6 | 7 | TLSF is free software; you can redistribute it and/or modify it under terms of 8 | the GNU General Public License as published by the Free Software Foundation; 9 | either version 2, or (at your option) any later version. TLSF is distributed 10 | in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 11 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 12 | the GNU General Public License for more details. You should have received a 13 | copy of the GNU General Public License along with TLSF; see file COPYING. If 14 | not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, 15 | USA. 16 | 17 | As a special exception, including TLSF header files in a file, or linking with 18 | other files objects to produce an executable application, is merely considered 19 | normal use of the library, and does *not* fall under the heading of "derived 20 | work". Therfore does not by itself cause the resulting executable application 21 | to be covered by the GNU General Public License. This exception does not 22 | however invalidate any other reasons why the executable file might be covered 23 | by the GNU Public License. 24 | -------------------------------------------------------------------------------- /allocators/TLSF/TLSF-2.4.6/TODO: -------------------------------------------------------------------------------- 1 | To do list 2 | ========== 3 | 4 | * Add mmap/sbrk support (DONE - V2.4). 5 | 6 | * TLSF rounds-up request size to the head of a free list. 7 | It has been shown to be a good policy for small blocks (<2048). 8 | But for larger blocks this policy may cause excesive fragmentation. 9 | A deeper analisys should be done. 10 | -------------------------------------------------------------------------------- /allocators/TLSF/TLSF-2.4.6/examples/Makefile: -------------------------------------------------------------------------------- 1 | all: test test1 test2 test3 test4 2 | 3 | TLSF_PATH=../src 4 | 5 | WARNINGS = -Wextra -Wall -Wwrite-strings -Wstrict-prototypes \ 6 | -Wmissing-prototypes -Wno-long-long -Wstrict-aliasing=2 7 | CFLAGS+=-g -O2 -I$(TLSF_PATH) $(WARNINGS) 8 | # CFLAGS+=-ftest-coverage -fprofile-arcs 9 | CC = gcc 10 | 11 | test: test.o $(TLSF_PATH)/tlsf.h 12 | $(CC) $(CFLAGS) -o test test.o $(TLSF_PATH)/tlsf.o 13 | 14 | test.o: test.c $(TLSF_PATH)/tlsf.h 15 | 16 | test1: test1.o $(TLSF_PATH)/tlsf.h 17 | $(CC) $(CFLAGS) -o test1 test1.o $(TLSF_PATH)/tlsf.o -lm 18 | 19 | test1.o: test1.c $(TLSF_PATH)/tlsf.h 20 | 21 | test2: test2.o $(TLSF_PATH)/tlsf.h 22 | $(CC) $(CFLAGS) -o test2 test2.o $(TLSF_PATH)/tlsf.o -lm 23 | 24 | test2.o: test2.c $(TLSF_PATH)/tlsf.h 25 | 26 | test3: test3.o $(TLSF_PATH)/tlsf.h 27 | $(CC) $(CFLAGS) -o test3 test3.o $(TLSF_PATH)/tlsf.o -lm 28 | 29 | test3.o: test3.c $(TLSF_PATH)/tlsf.h 30 | 31 | test4: test4.o $(TLSF_PATH)/tlsf.h 32 | $(CC) $(CFLAGS) -o test4 test4.o $(TLSF_PATH)/tlsf.o -lm 33 | 34 | test4.o: test4.c $(TLSF_PATH)/tlsf.h 35 | 36 | clean: 37 | $(RM) -rf *.o test test? *~ *.c.gcov *.gcda *.gcno 38 | -------------------------------------------------------------------------------- /allocators/TLSF/TLSF-2.4.6/examples/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "tlsf.h" 4 | 5 | #define POOL_SIZE 1024 * 1024 6 | 7 | 8 | // Pool size is in bytes. 9 | char pool[POOL_SIZE]; 10 | 11 | int 12 | main(void){ 13 | int *ptr[100]; 14 | int i, free_mem; 15 | 16 | free_mem = init_memory_pool(POOL_SIZE, pool); 17 | printf("Total free memory= %d\n", free_mem); 18 | for (i=0; i< 100; i++) 19 | if (!(ptr[i]=malloc_ex(1024, pool))){ 20 | printf("Error\n"); 21 | exit(-1); 22 | } 23 | for (i=0; i< 100; i++) 24 | free_ex(ptr[i], pool); 25 | 26 | destroy_memory_pool(pool); 27 | printf("Test OK\n"); 28 | exit(0); 29 | } 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /allocators/TLSF/TLSF-2.4.6/examples/test3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "tlsf.h" 4 | 5 | #define POOL_SIZE 1024 * 10 6 | 7 | 8 | // Pool size is in bytes. 9 | char p0[POOL_SIZE]; 10 | char p1[POOL_SIZE]; 11 | char p2[POOL_SIZE]; 12 | char p3[POOL_SIZE]; 13 | 14 | int main(void){ 15 | char *ptr; 16 | 17 | printf("Pools' addresses: (0) %p (1) %p (2) %p (3) %p\n", p0, p1, p2, p3); 18 | init_memory_pool(POOL_SIZE, p0); 19 | add_new_area(p3, POOL_SIZE, p0); 20 | add_new_area(p1, POOL_SIZE, p0); 21 | add_new_area(p2, POOL_SIZE, p0); 22 | 23 | if (!(ptr=malloc_ex(POOL_SIZE*2, p0))){ 24 | printf("Error\n"); 25 | exit(-1); 26 | } 27 | 28 | free_ex(ptr, p0); 29 | 30 | destroy_memory_pool(p0); 31 | printf("Test OK\n"); 32 | exit(0); 33 | } 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /allocators/TLSF/TLSF-2.4.6/examples/test4.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "tlsf.h" 4 | 5 | int main(void){ 6 | int *ptr[100]; 7 | int i; 8 | 9 | for (i=0; i< 100; i++) 10 | if (!(ptr[i]=tlsf_malloc(1024))){ 11 | printf("Error\n"); 12 | exit(-1); 13 | } 14 | 15 | for (i=0; i< 100; i++) 16 | tlsf_free(ptr[i]); 17 | 18 | printf("Test OK\n"); 19 | 20 | exit(0); 21 | } 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /allocators/TLSF/TLSF-2.4.6/src/Makefile: -------------------------------------------------------------------------------- 1 | WARNINGS = -Wextra -Wall -Wwrite-strings -Wstrict-prototypes \ 2 | -Wmissing-prototypes -Wno-long-long -Wstrict-aliasing=2 3 | 4 | HEAP_LAYERS = ../../../Heap-Layers 5 | 6 | CFLAGS+= -g -O2 -fPIC -I$(HEAP_LAYERS) # $(WARNINGS) 7 | CFLAGS+= -DTLSF_USE_LOCKS=1 8 | CFLAGS+= -DUSE_MMAP=1 9 | # CFLAGS+= -DUSE_SBRK=1 10 | 11 | # CFLAGS+=-ftest-coverage -fprofile-arcs 12 | CC=gcc 13 | 14 | all: tlsf.o libtlsf.so 15 | 16 | tlsf.o: tlsf.h tlsf.c Makefile 17 | 18 | tlsf-shim.o: tlsf-shim.cpp 19 | g++ $(CFLAGS) -c tlsf-shim.cpp 20 | 21 | libtlsf.so: tlsf-shim.o tlsf.o 22 | g++ $(CFLAGS) -shared tlsf-shim.o tlsf.o $(HEAP_LAYERS)/wrappers/gnuwrapper.cpp -o libtlsf.so -ldl 23 | 24 | clean: 25 | $(RM) -rf *.o *~ *.c.gcov *.gcda *.gcno 26 | 27 | indent: 28 | indent -kr -l120 -br -ce -npsl -nut -i4 *.[hc] 29 | 30 | -------------------------------------------------------------------------------- /allocators/TLSF/TLSF-2.4.6/src/target.h: -------------------------------------------------------------------------------- 1 | #ifndef _TARGET_H_ 2 | #define _TARGET_H_ 3 | 4 | #include 5 | 6 | #define TLSF_MLOCK_T pthread_mutex_t 7 | #define TLSF_CREATE_LOCK(l) pthread_mutex_init (l, NULL) 8 | #define TLSF_DESTROY_LOCK(l) pthread_mutex_destroy(l) 9 | #define TLSF_ACQUIRE_LOCK(l) pthread_mutex_lock(l) 10 | #define TLSF_RELEASE_LOCK(l) pthread_mutex_unlock(l) 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /allocators/TLSF/TLSF-2.4.6/src/tlsf-shim.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | 5 | void * tlsf_malloc (size_t); 6 | void tlsf_free (void *); 7 | size_t tlsf_get_object_size (void *); 8 | void tlsf_lock (void); 9 | void tlsf_unlock (void); 10 | 11 | void * xxmalloc (size_t sz) { 12 | return tlsf_malloc (sz); 13 | } 14 | 15 | void xxfree (void * ptr) { 16 | tlsf_free (ptr); 17 | } 18 | 19 | size_t xxmalloc_usable_size (void * ptr) { 20 | return tlsf_get_object_size (ptr); 21 | } 22 | 23 | void xxmalloc_lock() { 24 | tlsf_lock(); 25 | } 26 | 27 | void xxmalloc_unlock() { 28 | tlsf_unlock(); 29 | } 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /allocators/TLSF/TLSF-2.4.6/src/tlsf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Two Levels Segregate Fit memory allocator (TLSF) 3 | * Version 2.4.6 4 | * 5 | * Written by Miguel Masmano Tello 6 | * 7 | * Thanks to Ismael Ripoll for his suggestions and reviews 8 | * 9 | * Copyright (C) 2008, 2007, 2006, 2005, 2004 10 | * 11 | * This code is released using a dual license strategy: GPL/LGPL 12 | * You can choose the licence that better fits your requirements. 13 | * 14 | * Released under the terms of the GNU General Public License Version 2.0 15 | * Released under the terms of the GNU Lesser General Public License Version 2.1 16 | * 17 | */ 18 | 19 | #ifndef _TLSF_H_ 20 | #define _TLSF_H_ 21 | 22 | #include 23 | 24 | extern size_t init_memory_pool(size_t, void *); 25 | extern size_t get_used_size(void *); 26 | extern size_t get_max_size(void *); 27 | extern void destroy_memory_pool(void *); 28 | extern size_t add_new_area(void *, size_t, void *); 29 | extern void *malloc_ex(size_t, void *); 30 | extern void free_ex(void *, void *); 31 | extern void *realloc_ex(void *, size_t, void *); 32 | extern void *calloc_ex(size_t, size_t, void *); 33 | 34 | extern void *tlsf_malloc(size_t size); 35 | extern void tlsf_free(void *ptr); 36 | extern void *tlsf_realloc(void *ptr, size_t size); 37 | extern void *tlsf_calloc(size_t nelem, size_t elem_size); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /allocators/dlmalloc/dlmalloc272/compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | case "$OSTYPE" in 4 | darwin8.0) 5 | echo "Compiling for Darwin" 6 | g++ -pipe -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I../../heaplayers -D_REENTRANT=1 -compatibility_version 1 -current_version 1 -dynamiclib libdlmalloc.cpp dlmalloc.c -o libdlmalloc.dylib;; 7 | [Ll]inux*) 8 | echo "Compiling for Linux" 9 | g++ -pipe -march=pentiumpro -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I../../heaplayers -D_REENTRANT=1 -shared libdlmalloc.cpp dlmalloc.c -o libdlmalloc.so -ldl ;; 10 | solaris) 11 | echo "Compiling for Solaris" 12 | #CC -xildoff -native -noex -xipo=2 -xO5 -mt -DNDEBUG -I. -I.. -D_REENTRANT=1 -G -PIC libdlmalloc.cpp -o libdlmalloc.so;; 13 | # g++ -pipe -DNDEBUG -I. -I.. -D_REENTRANT=1 -fPIC -shared libdlmalloc.cpp -o libdlmalloc.so;; 14 | gcc -DUSE_MALLOC_LOCK=1 -fPIC -pipe -mcpu=ultrasparc -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -c dlmalloc.c 15 | g++ -fPIC -pipe -mcpu=ultrasparc -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I../../heaplayers -D_REENTRANT=1 -shared libdlmalloc.cpp dlmalloc.o -o libdlmalloc.so;; 16 | # g++ -pipe -mcpu=ultrasparc -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -shared libdlmalloc.cpp -o libdlmalloc.so;; 17 | *) 18 | echo "hmmm" 19 | esac 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /allocators/dlmalloc/dlmalloc272/compile-nolocks: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | case "$OSTYPE" in 4 | linux) 5 | echo "Compiling for Linux" 6 | g++ -pipe -march=pentium4 -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I../../heaplayers -D_REENTRANT=1 -shared dlmalloc.c -o libdlmalloc.so;; 7 | solaris) 8 | echo "Compiling for Solaris" 9 | #CC -xildoff -native -noex -xipo=2 -xO5 -mt -DNDEBUG -I. -I.. -D_REENTRANT=1 -G -PIC libdlmalloc.cpp -o libdlmalloc.so;; 10 | # g++ -pipe -DNDEBUG -I. -I.. -D_REENTRANT=1 -fPIC -shared libdlmalloc.cpp -o libdlmalloc.so;; 11 | gcc -fPIC -pipe -mcpu=ultrasparc -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -c dlmalloc.c 12 | g++ -fPIC -pipe -mcpu=ultrasparc -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I../../heaplayers -D_REENTRANT=1 -shared libdlmalloc.cpp dlmalloc.o -o libdlmalloc.so;; 13 | # g++ -pipe -mcpu=ultrasparc -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -shared libdlmalloc.cpp -o libdlmalloc.so;; 14 | *) 15 | echo "hmmm" 16 | esac 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /allocators/dlmalloc/dlmalloc282/compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | case "$OSTYPE" in 4 | [Ll]inux*) 5 | echo "Compiling for Linux" 6 | g++ -DUSE_MALLOC_LOCK=1 -pipe -march=pentium4 -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I../../heaplayers -D_REENTRANT=1 -shared libdlmalloc.cpp dlmalloc.c -o libdlmalloc.so;; 7 | solaris) 8 | echo "Compiling for Solaris" 9 | #CC -xildoff -native -noex -xipo=2 -xO5 -mt -DNDEBUG -I. -I.. -D_REENTRANT=1 -G -PIC libdlmalloc.cpp -o libdlmalloc.so;; 10 | # g++ -pipe -DNDEBUG -I. -I.. -D_REENTRANT=1 -fPIC -shared libdlmalloc.cpp -o libdlmalloc.so;; 11 | gcc -DUSE_MALLOC_LOCK=1 -fPIC -pipe -mcpu=ultrasparc -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -c dlmalloc.c 12 | g++ -fPIC -pipe -mcpu=ultrasparc -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I../../heaplayers -D_REENTRANT=1 -shared libdlmalloc.cpp dlmalloc.o -o libdlmalloc.so;; 13 | # g++ -pipe -mcpu=ultrasparc -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -shared libdlmalloc.cpp -o libdlmalloc.so;; 14 | *) 15 | echo "hmmm" 16 | esac 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /allocators/dlmalloc/dlmalloc282/compile-nolocks: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | case "$OSTYPE" in 4 | linux) 5 | echo "Compiling for Linux" 6 | g++ -pipe -march=pentium4 -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I../../heaplayers -D_REENTRANT=1 -shared dlmalloc.c -o libdlmalloc.so;; 7 | solaris) 8 | echo "Compiling for Solaris" 9 | #CC -xildoff -native -noex -xipo=2 -xO5 -mt -DNDEBUG -I. -I.. -D_REENTRANT=1 -G -PIC libdlmalloc.cpp -o libdlmalloc.so;; 10 | # g++ -pipe -DNDEBUG -I. -I.. -D_REENTRANT=1 -fPIC -shared libdlmalloc.cpp -o libdlmalloc.so;; 11 | gcc -fPIC -pipe -mcpu=ultrasparc -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -c dlmalloc.c 12 | g++ -fPIC -pipe -mcpu=ultrasparc -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I../../heaplayers -D_REENTRANT=1 -shared libdlmalloc.cpp dlmalloc.o -o libdlmalloc.so;; 13 | # g++ -pipe -mcpu=ultrasparc -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -shared libdlmalloc.cpp -o libdlmalloc.so;; 14 | *) 15 | echo "hmmm" 16 | esac 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /allocators/dlmalloc/dlmalloc282/libdlmalloc.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2003 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | /* 28 | * @file libdlmalloc.cpp 29 | * @brief This file replaces malloc etc. in your application. 30 | * @author Emery Berger 31 | */ 32 | 33 | #include 34 | #include 35 | 36 | class std::bad_alloc; 37 | 38 | extern "C" { 39 | void * dlmalloc (size_t); 40 | void dlfree (void *); 41 | size_t dlmalloc_usable_size (void *); 42 | } 43 | 44 | int anyThreadCreated = 1; 45 | 46 | class TheCustomHeapType { 47 | public: 48 | inline void * malloc (size_t sz) { 49 | return dlmalloc(sz); 50 | } 51 | inline void free (void * ptr) { 52 | dlfree(ptr); 53 | } 54 | inline size_t getSize (void * ptr) { 55 | return dlmalloc_usable_size (ptr); 56 | } 57 | }; 58 | 59 | 60 | inline static TheCustomHeapType * getCustomHeap (void) { 61 | static char thBuf[sizeof(TheCustomHeapType)]; 62 | static TheCustomHeapType * th = new (thBuf) TheCustomHeapType; 63 | return th; 64 | } 65 | 66 | #if defined(_WIN32) 67 | #pragma warning(disable:4273) 68 | #endif 69 | 70 | #include "wrapper.cpp" 71 | 72 | -------------------------------------------------------------------------------- /allocators/dlmalloc/dlmalloc285/compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | case "$OSTYPE" in 4 | [Ll]inux*) 5 | echo "Compiling for Linux" 6 | g++ -DUSE_MALLOC_LOCK=1 -pipe -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I../../heaplayers -D_REENTRANT=1 -shared libdlmalloc.cpp dlmalloc.c -o libdlmalloc.so;; 7 | solaris) 8 | echo "Compiling for Solaris" 9 | #CC -xildoff -native -noex -xipo=2 -xO5 -mt -DNDEBUG -I. -I.. -D_REENTRANT=1 -G -PIC libdlmalloc.cpp -o libdlmalloc.so;; 10 | # g++ -pipe -DNDEBUG -I. -I.. -D_REENTRANT=1 -fPIC -shared libdlmalloc.cpp -o libdlmalloc.so;; 11 | gcc -DUSE_MALLOC_LOCK=1 -fPIC -pipe -mcpu=ultrasparc -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -c dlmalloc.c 12 | g++ -fPIC -pipe -mcpu=ultrasparc -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I../../heaplayers -D_REENTRANT=1 -shared libdlmalloc.cpp dlmalloc.o -o libdlmalloc.so;; 13 | # g++ -pipe -mcpu=ultrasparc -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -shared libdlmalloc.cpp -o libdlmalloc.so;; 14 | *) 15 | echo "hmmm" 16 | esac 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /allocators/dlmalloc/dlmalloc285/libdlmalloc.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2003 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | /* 28 | * @file libdlmalloc.cpp 29 | * @brief This file replaces malloc etc. in your application. 30 | * @author Emery Berger 31 | */ 32 | 33 | #include 34 | #include 35 | 36 | class std::bad_alloc; 37 | 38 | extern "C" { 39 | void * dlmalloc (size_t); 40 | void dlfree (void *); 41 | size_t dlmalloc_usable_size (void *); 42 | } 43 | 44 | int anyThreadCreated = 1; 45 | 46 | class TheCustomHeapType { 47 | public: 48 | inline void * malloc (size_t sz) { 49 | return dlmalloc(sz); 50 | } 51 | inline void free (void * ptr) { 52 | dlfree(ptr); 53 | } 54 | inline size_t getSize (void * ptr) { 55 | return dlmalloc_usable_size (ptr); 56 | } 57 | }; 58 | 59 | 60 | inline static TheCustomHeapType * getCustomHeap (void) { 61 | static char thBuf[sizeof(TheCustomHeapType)]; 62 | static TheCustomHeapType * th = new (thBuf) TheCustomHeapType; 63 | return th; 64 | } 65 | 66 | #if defined(_WIN32) 67 | #pragma warning(disable:4273) 68 | #endif 69 | 70 | #include "wrapper.cpp" 71 | 72 | -------------------------------------------------------------------------------- /allocators/jemalloc/compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | case "$OSTYPE" in 4 | [Ll]inux*) 5 | echo "Compiling for Linux" 6 | gcc -DNO_LOCKS=1 -DMOZ_MEMORY=1 -DMOZ_MEMORY_LINUX=1 -pipe -march=pentium4 -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I../../heaplayers -D_REENTRANT=1 -shared jemalloc.c -o libjemalloc.so -lpthread;; 7 | solaris) 8 | echo "Compiling for Solaris" 9 | #CC -xildoff -native -noex -xipo=2 -xO5 -mt -DNDEBUG -I. -I.. -D_REENTRANT=1 -G -PIC libjemalloc.cpp -o libjemalloc.so;; 10 | # g++ -pipe -DNDEBUG -I. -I.. -D_REENTRANT=1 -fPIC -shared libjemalloc.cpp -o libjemalloc.so;; 11 | gcc -DUSE_MALLOC_LOCK=1 -fPIC -pipe -mcpu=ultrasparc -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -c jemalloc.c 12 | g++ -fPIC -pipe -mcpu=ultrasparc -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I../../heaplayers -D_REENTRANT=1 -shared libjemalloc.cpp jemalloc.o -o libjemalloc.so;; 13 | # g++ -pipe -mcpu=ultrasparc -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -shared libjemalloc.cpp -o libjemalloc.so;; 14 | *) 15 | echo "hmmm" 16 | esac 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /allocators/kmalloc/compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | case "$OSTYPE" in 4 | [Ll]inux*) 5 | echo "Compiling for Linux" 6 | g++ -pipe -mcpu=pentiumpro -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -I../../kmalloc -D_REENTRANT=1 -shared libkmalloc.cpp kmalloc.c -o libkmalloc.so;; 7 | solaris) 8 | echo "Compiling for Solaris" 9 | #CC -xildoff -native -noex -xipo=2 -xO5 -mt -DNDEBUG -I. -I.. -D_REENTRANT=1 -G -PIC libkmalloc.cpp -o libkmalloc.so;; 10 | # g++ -pipe -DNDEBUG -I. -I.. -D_REENTRANT=1 -fPIC -shared libkmalloc.cpp -o libkmalloc.so;; 11 | gcc -fPIC -pipe -g -I. -I../../heaplayers -D_REENTRANT=1 -c kmalloc.c 12 | # gcc -fPIC -pipe -mcpu=ultrasparc -O3 -finline-limit=500 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -c kmalloc.c 13 | g++ -fPIC -pipe -g -I. -I../../heaplayers -D_REENTRANT=1 -shared libkmalloc.cpp kmalloc.o -o libkmalloc.so;; 14 | # g++ -fPIC -pipe -mcpu=ultrasparc -O3 -finline-limit=500 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I../../heaplayers -D_REENTRANT=1 -shared libkmalloc.cpp kmalloc.o -o libkmalloc.so;; 15 | # g++ -pipe -mcpu=ultrasparc -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -shared libkmalloc.cpp -o libkmalloc.so;; 16 | *) 17 | echo "hmmm" 18 | esac 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /allocators/kmalloc/libkmalloc.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2003 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | /* 28 | * @file libkingsley.cpp 29 | * @brief This file replaces malloc etc. in your application. 30 | * @author Emery Berger 31 | */ 32 | 33 | #include 34 | #include 35 | 36 | class std::bad_alloc; 37 | 38 | extern "C" { 39 | void * kmalloc (size_t); 40 | void kfree (void *); 41 | size_t kmalloc_usable_size (void *); 42 | } 43 | 44 | int anyThreadCreated = 1; 45 | 46 | class TheCustomHeapType { 47 | public: 48 | inline void * malloc (size_t sz) { 49 | return kmalloc(sz); 50 | } 51 | inline void free (void * ptr) { 52 | kfree(ptr); 53 | } 54 | inline size_t getSize (void * ptr) { 55 | return kmalloc_usable_size (ptr); 56 | } 57 | }; 58 | 59 | 60 | inline static TheCustomHeapType * getCustomHeap (void) { 61 | static char thBuf[sizeof(TheCustomHeapType)]; 62 | static TheCustomHeapType * th = new (thBuf) TheCustomHeapType; 63 | return th; 64 | } 65 | 66 | #if defined(_WIN32) 67 | #pragma warning(disable:4273) 68 | #endif 69 | 70 | #include "wrapper.cpp" 71 | 72 | -------------------------------------------------------------------------------- /allocators/nedmalloc/Benchmarks.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/nedmalloc/Benchmarks.xls -------------------------------------------------------------------------------- /allocators/nedmalloc/License.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /allocators/nedmalloc/nedmalloc.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nedmalloc", "nedmalloc.vcproj", "{B89384F5-360B-4AB2-8F43-2F5F98A947FE}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfiguration) = preSolution 8 | Debug = Debug 9 | Release = Release 10 | EndGlobalSection 11 | GlobalSection(ProjectConfiguration) = postSolution 12 | {B89384F5-360B-4AB2-8F43-2F5F98A947FE}.Debug.ActiveCfg = Debug|Win32 13 | {B89384F5-360B-4AB2-8F43-2F5F98A947FE}.Debug.Build.0 = Debug|Win32 14 | {B89384F5-360B-4AB2-8F43-2F5F98A947FE}.Release.ActiveCfg = Release|Win32 15 | {B89384F5-360B-4AB2-8F43-2F5F98A947FE}.Release.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(ExtensibilityGlobals) = postSolution 18 | EndGlobalSection 19 | GlobalSection(ExtensibilityAddIns) = postSolution 20 | EndGlobalSection 21 | EndGlobal 22 | -------------------------------------------------------------------------------- /allocators/old/streamflow/Makefile: -------------------------------------------------------------------------------- 1 | # How do we figure out the meta information for an object? 2 | # Options: 3 | # - HEADERS 4 | # - BIBOP 5 | # - RADIX_TREE 6 | META_METHOD = BIBOP 7 | 8 | # What architecture are we on? 9 | # Options: 10 | # - ppc64 (IBM PowerPC, 64-bit) 11 | # - x86 (Intel x86, 32-bit) 12 | ASM = x86 13 | 14 | ifeq ($(ASM), ppc64) 15 | BITS = 64 16 | FPIC = -fPIC 17 | endif 18 | ifeq ($(ASM), x86) 19 | BITS = 32 20 | endif 21 | ifndef BITS 22 | $(error Need to define ASM.) 23 | endif 24 | 25 | CC = gcc 26 | CXX = g++ 27 | 28 | LDFLAGS = -lpthread -lm -ldl 29 | CFLAGS = -D_REENTRANT -D$(ASM) -D$(META_METHOD) 30 | #CFLAGS += -DSUPERPAGES 31 | #CFLAGS += -DMEMORY 32 | #CFLAGS += -DCOLOR 33 | 34 | GCC_CFLAGS = -D_GNU_SOURCE -Wall -m$(BITS) -fno-strict-aliasing $(FPIC) 35 | GCC_OPT = -O3 -pipe -finline-functions -fomit-frame-pointer 36 | 37 | ICC_CFLAGS = -wd279 -wd981 -wd1418 -wd1469 -wd383 -wd869 -wd522 -wd810 -wd1684 -wd1338 -wd1684 -D_GNU_SOURCE 38 | ICC_OPT = -O3 -pipe -finline-functions -fomit-frame-pointer 39 | 40 | XLC_CFLAGS = -q64 -qabi_version=2 -qasm=gcc 41 | XLC_OPT = -O4 42 | 43 | ifeq ($(CC), gcc) 44 | OPT = $(GCC_OPT) 45 | CFLAGS += $(GCC_CFLAGS) 46 | endif 47 | ifeq ($(CC), icc) 48 | OPT = $(ICC_OPT) 49 | CFLAGS += $(ICC_CFLAGS) 50 | endif 51 | ifeq ($(CC), xlc_r) 52 | OPT = $(XLC_OPT) 53 | CFLAGS += $(XLC_CFLAGS) 54 | endif 55 | ifndef OPT 56 | $(error Need to define CC.) 57 | endif 58 | 59 | # Rules. 60 | 61 | all: libstreamflow.so recycle larson 62 | 63 | clean: 64 | rm -f *.o *.so recycle larson 65 | 66 | streamflow.o: streamflow.h streamflow.c 67 | $(CC) $(CFLAGS) $(OPT) -Iinclude-$(ASM) -c streamflow.c 68 | 69 | malloc_new.o: malloc_new.cpp streamflow.h 70 | $(CXX) $(CFLAGS) $(OPT) -Iinclude-$(ASM) -c malloc_new.cpp 71 | 72 | override.o: override.c streamflow.h 73 | $(CC) $(CFLAGS) $(OPT) -Iinclude-$(ASM) -c override.c 74 | 75 | libstreamflow.so: malloc_new.o streamflow.o override.o 76 | $(CXX) $(CFLAGS) $(OPT) override.o streamflow.o malloc_new.o -o libstreamflow.so $(LDFLAGS) -lstdc++ -shared 77 | 78 | recycle: recycle.c 79 | $(CC) $(CFLAGS) $(OPT) -o recycle recycle.c $(LDFLAGS) 80 | 81 | larson: larson.cpp 82 | $(CXX) $(CFLAGS) $(OPT) -o larson larson.cpp $(LDFLAGS) 83 | 84 | -------------------------------------------------------------------------------- /allocators/old/streamflow/README: -------------------------------------------------------------------------------- 1 | Streamflow 2 | http://www.cs.wm.edu/streamflow 3 | 4 | --- 5 | Project contributors 6 | --- 7 | Scott Schneider, scotts@cs.wm.edu 8 | Christos Antonopoulos, cda@cs.wm.edu 9 | Dimitrios Nikolopoulos, dsn@cs.wm.edu 10 | 11 | --- 12 | Notes 13 | --- 14 | 15 | Compiling: 16 | - In the Makefile, define a META_METHOD as one of HEADERS, 17 | BIBOP or RADIX_TREE. All architectures support HEADERS. Only 18 | 32-bit architectures support BIBOP, and only 64-bit architectures 19 | support RADIX_TREE. 20 | - In the Makefile, define ASM as either x86 or ppc64. These are the 21 | only supported architectures at this time. 22 | 23 | gcc 3.3.4: 24 | - Streamflow does not compile with gcc 3.3.4; it causes an internal 25 | compiler error when full optimizations are turned on. It has been 26 | successfuly compiled with gcc 4.0.2 and gcc 3.4.5. 27 | 28 | Superpages: 29 | - Streamflow expects superpages to be mounted on /mnt/huge. 30 | - Multiple processes can use superpages, but they communicate 31 | through the file system. Files created in /tmp/supermap are 32 | considered legal superpage names. Successfuly unlinking a file 33 | in /tmp/supermap claims ownership of that file name, and allows 34 | a process to use it in /mnt/huge. Files must be recreated on 35 | each subsequent run. 36 | 37 | Machine dependent files: 38 | - atomic.h and bitops.h are taken from the Linux kernel source, 39 | with minor modifications. 40 | -------------------------------------------------------------------------------- /allocators/old/streamflow/lock.h: -------------------------------------------------------------------------------- 1 | #ifndef __LOCK_H_ 2 | #define __LOCK_H_ 3 | 4 | #include "atomic.h" 5 | 6 | typedef volatile unsigned int lock_t; 7 | 8 | void spin_init(lock_t *lock); 9 | void spin_lock(register lock_t *lock); 10 | void spin_unlock(register lock_t *lock); 11 | 12 | struct incr_barrier { 13 | unsigned long num_threads; 14 | volatile unsigned long arrived; 15 | volatile unsigned long global_sense; 16 | }; 17 | typedef struct incr_barrier barrier_t; 18 | 19 | void bar_init(barrier_t *barr, unsigned long num_threads); 20 | void bar(barrier_t *barr); 21 | 22 | #define spin_init(lock) \ 23 | {\ 24 | *(lock) = 0; \ 25 | } 26 | 27 | #define spin_lock(lock) \ 28 | {\ 29 | while (fetch_and_store((volatile unsigned int *)(lock), 1)) { \ 30 | while(*(lock)); \ 31 | } \ 32 | } 33 | 34 | #define spin_unlock(lock) \ 35 | {\ 36 | *(lock) = 0; \ 37 | } 38 | 39 | #define bar_init(barr, num_threads) \ 40 | {\ 41 | (barr)->global_sense = 0; \ 42 | (barr)->arrived = 0; \ 43 | (barr)->num_threads = (num_threads); \ 44 | } 45 | 46 | #define bar(barr) \ 47 | {\ 48 | unsigned long local_sense, my_num; \ 49 | \ 50 | local_sense = (barr)->global_sense; \ 51 | my_num = fetch_and_add(&((barr)->arrived), 1); \ 52 | if (my_num == (barr)->num_threads - 1) { \ 53 | (barr)->arrived = 0; \ 54 | (barr)->global_sense = !(barr)->global_sense; \ 55 | } \ 56 | else { \ 57 | while(local_sense == (barr)->global_sense); \ 58 | } \ 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /allocators/old/streamflow/malloc_new.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | void* malloc(size_t); 5 | void free(void*); 6 | } 7 | 8 | void* operator new(size_t sz) throw (std::bad_alloc) 9 | { 10 | return malloc(sz); 11 | } 12 | 13 | void * operator new(size_t sz, const std::nothrow_t&) throw() 14 | { 15 | return malloc(sz); 16 | } 17 | 18 | void operator delete(void * ptr) 19 | { 20 | free(ptr); 21 | } 22 | 23 | void* operator new[](size_t sz) throw (std::bad_alloc) 24 | { 25 | return malloc(sz); 26 | } 27 | 28 | void * operator new[](size_t sz, const std::nothrow_t&) throw() 29 | { 30 | return malloc(sz); 31 | } 32 | 33 | void operator delete[](void * ptr) 34 | { 35 | free(ptr); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /allocators/old/streamflow/malloc_new.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __MALLOC_NEW_H__ 3 | #define __MALLOC_NEW_H__ 4 | 5 | extern "C" { 6 | #include "ccmm.h" 7 | } 8 | 9 | #include 10 | 11 | void* operator new(std::size_t sz) throw (std::bad_alloc) 12 | { 13 | return malloc (sz); 14 | } 15 | 16 | void * operator new (size_t sz, const std::nothrow_t&) throw() 17 | { 18 | return malloc (sz); 19 | } 20 | 21 | void operator delete (void * ptr) 22 | { 23 | free (ptr); 24 | } 25 | 26 | void* operator new[](std::size_t sz) throw (std::bad_alloc) 27 | { 28 | return malloc (sz); 29 | } 30 | 31 | void * operator new[] (size_t sz, const std::nothrow_t&) throw() 32 | { 33 | return malloc (sz); 34 | } 35 | 36 | void operator delete[] (void * ptr) 37 | { 38 | free (ptr); 39 | } 40 | 41 | #endif // __MALLOC_NEW_H__ 42 | 43 | -------------------------------------------------------------------------------- /allocators/old/streamflow/recycle.c: -------------------------------------------------------------------------------- 1 | /* 2 | * recycle.c 3 | * 4 | * Scott Schneider 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | size_t min_size; 12 | size_t max_size; 13 | int iterations = (int)1e8; 14 | int rate; 15 | 16 | double random_number() 17 | { 18 | static long int seed = 547845897; 19 | static long int m = 2147483647; // m is the modulus, m = 2 ^ 31 - 1 20 | static long int a = 16807; // a is the multiplier, a = 7 ^ 5 21 | static long int q = 127773; // q is the floor of m / a 22 | static long int r = 2836; // r is m mod a 23 | 24 | long int temp = a * (seed % q) - r * (seed / q); 25 | 26 | if (temp > 0) { 27 | seed = temp; 28 | } 29 | else { 30 | seed = temp + m; 31 | } 32 | 33 | return (double)seed / (double)m; 34 | } 35 | 36 | void* simulate_work(void* arg) 37 | { 38 | void** reserve = (void**)malloc(rate * sizeof(void*)); 39 | int i; 40 | int j; 41 | double rand; 42 | size_t object_size; 43 | 44 | for (i = 0; i < iterations; ++i) { 45 | 46 | if (i % rate == 0 && i != 0) { 47 | for (j = 0; j < rate; ++j) { 48 | free(reserve[j]); 49 | } 50 | } 51 | 52 | rand = random_number(); 53 | object_size = min_size + (rand * (max_size - min_size)); 54 | reserve[i % rate] = malloc(object_size); 55 | } 56 | 57 | free(reserve); 58 | 59 | return NULL; 60 | } 61 | 62 | int main(int argc, char* argv[]) 63 | { 64 | pthread_t* threads; 65 | 66 | 67 | int num_threads = atoi(argv[1]); 68 | min_size = atoi(argv[2]); 69 | max_size = atoi(argv[3]); 70 | rate = atoi(argv[4]); 71 | 72 | iterations /= num_threads; 73 | 74 | threads = (pthread_t*)malloc(num_threads * sizeof(pthread_t)); 75 | 76 | int i; 77 | for (i = 0; i < num_threads-1; ++i) { 78 | pthread_create(&threads[i], NULL, simulate_work, NULL); 79 | } 80 | 81 | simulate_work(NULL); 82 | 83 | for (i = 0; i < num_threads-1; ++i) { 84 | pthread_join(threads[i], NULL); 85 | } 86 | 87 | return 0; 88 | } 89 | 90 | -------------------------------------------------------------------------------- /allocators/omalloc/Makefile: -------------------------------------------------------------------------------- 1 | LIB = libomalloc.so 2 | 3 | CFLAGS = -fPIC -O3 -DNDEBUG 4 | CC = gcc 5 | CXX = g++ 6 | 7 | SRCS = omalloc.c random.c issetugid.c 8 | OBJS = omalloc.o random.o issetugid.o 9 | 10 | %.o: %.c 11 | $(CC) $(CFLAGS) -c $< 12 | 13 | $(LIB): gnuwrapper.cpp $(OBJS) 14 | $(CXX) $(CFLAGS) -shared gnuwrapper.cpp $(OBJS) -o $(LIB) 15 | 16 | clean: 17 | -rm $(LIB) $(OBJS) 18 | 19 | 20 | -------------------------------------------------------------------------------- /allocators/omalloc/issetugid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) - 2007 Robert Connolly 3 | * 4 | * Permission to reproduce, copy, delete, distribute, transmit, use, modify, 5 | * build upon or otherwise exploit this software, in any form, for any 6 | * purpose, in any way, and by anyone, including by methods that have not 7 | * yet been invented or conceived, is hereby granted. 8 | */ 9 | 10 | #include 11 | 12 | extern int __libc_enable_secure; 13 | 14 | int issetugid(void) 15 | { 16 | if (__libc_enable_secure) 17 | { 18 | return 1; 19 | } 20 | 21 | if (getuid() != geteuid()) 22 | { 23 | return 1; 24 | } 25 | 26 | if (getgid() != getegid()) 27 | { 28 | return 1; 29 | } 30 | 31 | /* Else */ 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /allocators/ottomalloc/Makefile: -------------------------------------------------------------------------------- 1 | phk: 2 | gcc -g -fPIC -pipe -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -DNDEBUG -UDEBUG -D_REENTRANT=1 -c ottomalloc_linux.c 3 | gcc -g -fPIC -pipe -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -DNDEBUG -UDEBUG -D_REENTRANT=1 -c arc4random.c 4 | g++ -g -fPIC -pipe -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -DNDEBUG -UDEBUG -D_REENTRANT=1 -I../../heaplayers -I../../heaplayers/util -shared -D'CUSTOM_PREFIX(x)=otto_##x' gnuwrapper.cpp arc4random.o ottomalloc_linux.o -o libottomalloc.so -ldl 5 | 6 | phk_objs: 7 | gcc -O3 -finline-functions -fkeep-inline-functions -ffast-math -fomit-frame-pointer -pipe -DNDEBUG -UDEBUG -c phkmalloc_linux.c 8 | g++ -O3 -finline-functions -fkeep-inline-functions -ffast-math -fomit-frame-pointer -pipe -DNDEBUG -UDEBUG -I../../heaplayers -c libphkmalloc.cpp 9 | g++ -O3 -finline-functions -fkeep-inline-functions -ffast-math -fomit-frame-pointer -pipe -DNDEBUG -UDEBUG -shared libphkmalloc.o phkmalloc_linux.o -o libphkmalloc.so 10 | 11 | -------------------------------------------------------------------------------- /allocators/ottomalloc/libottomalloc.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | #include "ottomallocheap.h" 7 | 8 | using namespace HL; 9 | volatile int anyThreadCreated = 0; 10 | 11 | class TheCustomHeapType : public OttoMallocHeap {}; 12 | 13 | inline static TheCustomHeapType * getCustomHeap() { 14 | static char thBuf[sizeof(TheCustomHeapType)]; 15 | static TheCustomHeapType * th = new (thBuf) TheCustomHeapType; 16 | return th; 17 | } 18 | 19 | #include "wrapper.cpp" 20 | -------------------------------------------------------------------------------- /allocators/ottomalloc/ottomallocheap.h: -------------------------------------------------------------------------------- 1 | #ifndef _OTTOMALLOCHEAP_H_ 2 | #define _OTTOMALLOCHEAP_H_ 3 | 4 | extern "C" { 5 | void * otto_malloc(size_t); 6 | void otto_free(void *); 7 | void * otto_realloc(void *, size_t); 8 | void * otto_calloc(size_t, size_t); 9 | size_t otto_getsize(void * ptr); 10 | } 11 | 12 | namespace HL { 13 | 14 | class OttoMallocHeap { 15 | public: 16 | inline void * malloc(size_t sz) { 17 | return otto_malloc(sz); 18 | } 19 | 20 | inline void free(void * ptr) { 21 | otto_free(ptr); 22 | } 23 | 24 | inline size_t getSize(void * ptr) { 25 | return otto_getsize(ptr); 26 | } 27 | 28 | inline void * realloc(void * ptr, size_t sz) { 29 | return otto_realloc(ptr, sz); 30 | } 31 | }; //end of class OttoMallocHeap 32 | 33 | }; //end of namespace HL 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /allocators/phkmalloc/Makefile: -------------------------------------------------------------------------------- 1 | phk: 2 | gcc -pipe -mcpu=pentiumpro -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -UDEBUG -D_REENTRANT=1 -c phkmalloc_linux.c 3 | g++ -pipe -mcpu=pentiumpro -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -UDEBUG -D_REENTRANT=1 -I../../heaplayers -shared libphkmalloc.cpp phkmalloc_linux.o -o libphkmalloc.so 4 | 5 | phk_sc: 6 | gcc -pipe -mcpu=pentiumpro -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -UDEBUG -D_REENTRANT=1 -c phkmalloc_sc.c 7 | g++ -pipe -mcpu=pentiumpro -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -UDEBUG -D_REENTRANT=1 -I../../heaplayers -shared libphkmalloc.cpp phkmalloc_sc.o -o libphkmalloc_sc.so 8 | 9 | phk_reap: 10 | gcc -pipe -mcpu=pentiumpro -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -UDEBUG -D_REENTRANT=1 -c phkmalloc_reap.c 11 | g++ -pipe -mcpu=pentiumpro -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -UDEBUG -D_REENTRANT=1 -I../../heaplayers -shared libphkmalloc.cpp phkmalloc_reap.o -o libphkmalloc_reap.so 12 | 13 | phk_sc_reap: 14 | gcc -pipe -mcpu=pentiumpro -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -UDEBUG -D_REENTRANT=1 -c phkmalloc_sc_reap.c 15 | g++ -pipe -mcpu=pentiumpro -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -UDEBUG -D_REENTRANT=1 -I../../heaplayers -shared libphkmalloc.cpp phkmalloc_sc_reap.o -o libphkmalloc_sc_reap.so 16 | 17 | debug: 18 | gcc -g -c phkmalloc_linux_vmcomm.c 19 | g++ -g -DDEBUG -I../../heaplayers -shared libphkmalloc.cpp phkmalloc_linux_vmcomm.o -o libdebug.so 20 | # gcc -g -c phkmalloc_linux.c 21 | # g++ -g -DDEBUG -I../../heaplayers -shared libphkmalloc.cpp phkmalloc_linux.o -o libphkmalloc.so 22 | 23 | clean: 24 | rm *.so *.o 25 | 26 | phk_objs: 27 | gcc -O3 -finline-functions -fkeep-inline-functions -ffast-math -fomit-frame-pointer -pipe -DNDEBUG -UDEBUG -c phkmalloc_linux.c 28 | g++ -O3 -finline-functions -fkeep-inline-functions -ffast-math -fomit-frame-pointer -pipe -DNDEBUG -UDEBUG -I../../heaplayers -c libphkmalloc.cpp 29 | g++ -O3 -finline-functions -fkeep-inline-functions -ffast-math -fomit-frame-pointer -pipe -DNDEBUG -UDEBUG -shared libphkmalloc.o phkmalloc_linux.o -o libphkmalloc.so 30 | 31 | -------------------------------------------------------------------------------- /allocators/phkmalloc/compile: -------------------------------------------------------------------------------- 1 | #g++ -I../../heaplayers -g -O3 -DNDEBUG -c libphk.cpp 2 | # g++ -O3 -DNDEBUG -c sealer.cpp 3 | gcc -g -O3 -DNDEBUG -shared phkmalloc_linux.c -o libphk.so -ldl 4 | #g++ -shared -O3 phkmalloc_linux.o sealer.o libphk.o -o libphk.so -ldl 5 | #g++ -shared -O3 -g phkmalloc_linux.o libphk.o -o libphk.so -ldl 6 | -------------------------------------------------------------------------------- /allocators/phkmalloc/libphk.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | void * phkmalloc (size_t); 5 | void phkfree (void *); 6 | size_t phkmalloc_usable_size (void *); 7 | } 8 | 9 | 10 | class TheCustomHeapType { 11 | public: 12 | inline void * malloc (size_t sz) { 13 | return phkmalloc (sz); 14 | } 15 | inline void free (void * ptr) { 16 | phkfree (ptr); 17 | } 18 | inline size_t getSize (void * ptr) { 19 | return phkmalloc_usable_size (ptr); 20 | } 21 | }; 22 | 23 | TheCustomHeapType * getCustomHeap (void) { 24 | static TheCustomHeapType tHeap; 25 | return &tHeap; 26 | } 27 | 28 | #include "wrapper.cpp" 29 | -------------------------------------------------------------------------------- /allocators/phkmalloc/libphkmalloc.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "heaplayers.h" 5 | #include "phkmallocheap.h" 6 | 7 | using namespace HL; 8 | volatile int anyThreadCreated = 0; 9 | 10 | 11 | #ifdef DEBUG 12 | class TheCustomHeapType : public ANSIWrapper > {}; 13 | #else 14 | class TheCustomHeapType : public ANSIWrapper {}; 15 | #endif 16 | 17 | inline static TheCustomHeapType * getCustomHeap() { 18 | static char thBuf[sizeof(TheCustomHeapType)]; 19 | static TheCustomHeapType * th = new (thBuf) TheCustomHeapType; 20 | return th; 21 | } 22 | 23 | #include "wrapper.cpp" 24 | -------------------------------------------------------------------------------- /allocators/phkmalloc/phkmallocheap.h: -------------------------------------------------------------------------------- 1 | #ifndef _PHKMALLOCHEAP_H_ 2 | #define _PHKMALLOCHEAP_H_ 3 | 4 | extern "C" { 5 | void * phkmalloc(size_t); 6 | void phkfree(void *); 7 | //void * phkrealloc(void *, size_t); 8 | size_t phkgetsize(void *); 9 | } 10 | 11 | namespace HL { 12 | 13 | class PhkMallocHeap { 14 | public: 15 | inline void * malloc(size_t sz) { 16 | return phkmalloc(sz); 17 | } 18 | 19 | inline void free(void * ptr) { 20 | phkfree(ptr); 21 | } 22 | /* 23 | inline void * realloc(void * ptr, size_t sz) { 24 | return phkrealloc(ptr, sz); 25 | } 26 | */ 27 | inline size_t getSize(void * ptr) { 28 | return phkgetsize(ptr); 29 | } 30 | }; //end of class PhkMallocHeap 31 | 32 | }; //end of namespace HL 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /allocators/ptmalloc/ptmalloc2/COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2001 Wolfram Gloger 2 | 3 | Permission to use, copy, modify, distribute, and sell this software 4 | and its documentation for any purpose is hereby granted without fee, 5 | provided that (i) the above copyright notices and this permission 6 | notice appear in all copies of the software and related documentation, 7 | and (ii) the name of Wolfram Gloger may not be used in any advertising 8 | or publicity relating to the software. 9 | 10 | THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 11 | EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 12 | WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | IN NO EVENT SHALL WOLFRAM GLOGER BE LIABLE FOR ANY SPECIAL, 15 | INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY 16 | DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 17 | WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY 18 | OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 19 | PERFORMANCE OF THIS SOFTWARE. 20 | -------------------------------------------------------------------------------- /allocators/ptmalloc/ptmalloc2/ChangeLog: -------------------------------------------------------------------------------- 1 | 2002-11-18 Wolfram Gloger 2 | 3 | * malloc/arena.c 4 | (ptmalloc_lock_all, ptmalloc_unlock_all, ptmalloc_unlock_all2): Do 5 | nothing if not initialized. Bug report from Marcus Brinkmann 6 | . 7 | 8 | 2002-10-07 Wolfram Gloger 9 | 10 | * malloc/malloc.c (sYSMALLOc): Only check for breakage due 11 | to foreign sbrk()'s if arena is contiguous. Bug report from 12 | Bruno Haible . 13 | 14 | 2002-07-11 Wolfram Gloger 15 | 16 | * malloc/hooks.c: typo fix in NO_THREADS case, realloc_check 17 | fix in HAVE_MREMAP case. 18 | 19 | 2002-06-11 Wolfram Gloger 20 | 21 | * malloc/malloc.c: Fix error path when new_heap() returns NULL. 22 | Reported by Michael Meissner . 23 | 24 | 2002-03-29 Wolfram Gloger 25 | 26 | * malloc/malloc.c: Add short description and prototypes for 27 | malloc_get_state, malloc_set_state and posix_memalign, for 28 | consistency and to avoid warnings with -Wstrict-prototypes. 29 | Reported by Andreas Jaeger . 30 | 31 | 2002-03-13 Wolfram Gloger 32 | 33 | * malloc/malloc.c (sYSMALLOc): Don't change brk if mmap 34 | failed. 35 | 36 | 2002-01-18 Wolfram Gloger 37 | 38 | * malloc/malloc.c: Rewrite, adapted from Doug Lea's malloc-2.7.0.c. 39 | * malloc/malloc.h: Likewise. 40 | * malloc/arena.c: New file. 41 | * malloc/hooks.c: New file. 42 | * malloc/tst-mallocstate.c: New file. 43 | * malloc/Makefile: Add new testcase tst-mallocstate. 44 | Add arena.c and hooks.c to distribute. Fix commented CPPFLAGS. 45 | -------------------------------------------------------------------------------- /allocators/ptmalloc/ptmalloc2/compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | case "$OSTYPE" in 4 | [Ll]inux*) 5 | echo "Compiling for Linux" 6 | g++ -pipe -march=pentiumpro -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -shared malloc.c -o libptmalloc.so;; 7 | solaris) 8 | echo "Compiling for Solaris" 9 | #CC -xildoff -native -noex -xipo=2 -xO5 -mt -DNDEBUG -I. -I.. -D_REENTRANT=1 -G -PIC malloc.c -o libptmalloc.so;; 10 | # g++ -pipe -DNDEBUG -I. -I.. -D_REENTRANT=1 -fPIC -shared malloc.c -o libptmalloc.so;; 11 | gcc -DMALLOC_HOOKS -DUSE_PTHREADS=1 -D_REENTRANT -DUSE_TSD_DATA_HACK -fPIC -pipe -march=ultrasparc -O3 -finline-limit=10000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -c malloc.c 12 | g++ -fPIC -pipe -march=ultrasparc -O3 -finline-limit=10000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -I../../heaplayers -D_REENTRANT=1 -shared malloc.c -o libptmalloc.so;; 13 | # g++ -pipe -march=ultrasparc -O3 -finline-limit=10000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -shared malloc.c -o libptmalloc.so -lpthread;; 14 | *) 15 | echo "hmmm" 16 | esac 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /allocators/ptmalloc/ptmalloc2/libptmalloc.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | /* 4 | 5 | Heap Layers: An Extensible Memory Allocation Infrastructure 6 | 7 | Copyright (C) 2000-2003 by Emery Berger 8 | http://www.cs.umass.edu/~emery 9 | emery@cs.umass.edu 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | /* 28 | * @file libptmalloc.cpp 29 | * @brief This file replaces malloc etc. in your application. 30 | * @author Emery Berger 31 | */ 32 | 33 | #include 34 | #include 35 | 36 | class std::bad_alloc; 37 | 38 | extern "C" { 39 | void * dlmalloc (size_t); 40 | void dlfree (void *); 41 | size_t dlmalloc_usable_size (void *); 42 | } 43 | 44 | int anyThreadCreated = 1; 45 | 46 | class TheCustomHeapType { 47 | public: 48 | inline void * malloc (size_t sz) { 49 | return dlmalloc(sz); 50 | } 51 | inline void free (void * ptr) { 52 | dlfree(ptr); 53 | } 54 | inline size_t getSize (void * ptr) { 55 | return dlmalloc_usable_size (ptr); 56 | } 57 | }; 58 | 59 | 60 | inline static TheCustomHeapType * getCustomHeap (void) { 61 | static char thBuf[sizeof(TheCustomHeapType)]; 62 | static TheCustomHeapType * th = new (thBuf) TheCustomHeapType; 63 | return th; 64 | } 65 | 66 | #if defined(_WIN32) 67 | #pragma warning(disable:4273) 68 | #endif 69 | 70 | #include "wrapper.cpp" 71 | 72 | -------------------------------------------------------------------------------- /allocators/ptmalloc/ptmalloc2/lran2.h: -------------------------------------------------------------------------------- 1 | /* lran2.h 2 | * by Wolfram Gloger 1996. 3 | * 4 | * A small, portable pseudo-random number generator. 5 | */ 6 | 7 | #ifndef _LRAN2_H 8 | #define _LRAN2_H 9 | 10 | #define LRAN2_MAX 714025l /* constants for portable */ 11 | #define IA 1366l /* random number generator */ 12 | #define IC 150889l /* (see e.g. `Numerical Recipes') */ 13 | 14 | struct lran2_st { 15 | long x, y, v[97]; 16 | }; 17 | 18 | static void 19 | lran2_init(struct lran2_st* d, long seed) 20 | { 21 | long x; 22 | int j; 23 | 24 | x = (IC - seed) % LRAN2_MAX; 25 | if(x < 0) x = -x; 26 | for(j=0; j<97; j++) { 27 | x = (IA*x + IC) % LRAN2_MAX; 28 | d->v[j] = x; 29 | } 30 | d->x = (IA*x + IC) % LRAN2_MAX; 31 | d->y = d->x; 32 | } 33 | 34 | #ifdef __GNUC__ 35 | __inline__ 36 | #endif 37 | static long 38 | lran2(struct lran2_st* d) 39 | { 40 | int j = (d->y % 97); 41 | 42 | d->y = d->v[j]; 43 | d->x = (IA*d->x + IC) % LRAN2_MAX; 44 | d->v[j] = d->x; 45 | return d->y; 46 | } 47 | 48 | #undef IA 49 | #undef IC 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /allocators/ptmalloc/ptmalloc2/tst-mallocstate.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2001 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | Contributed by Wolfram Gloger , 2001. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #include 21 | #include 22 | #include "malloc.h" 23 | 24 | static int errors = 0; 25 | 26 | static void 27 | merror (const char *msg) 28 | { 29 | ++errors; 30 | printf ("Error: %s\n", msg); 31 | } 32 | 33 | int 34 | main (void) 35 | { 36 | void *p1, *p2; 37 | void *save_state; 38 | long i; 39 | 40 | errno = 0; 41 | 42 | p1 = malloc (10); 43 | if (p1 == NULL) 44 | merror ("malloc (10) failed."); 45 | 46 | p2 = malloc (20); 47 | if (p2 == NULL) 48 | merror ("malloc (20) failed."); 49 | 50 | free (malloc (10)); 51 | 52 | for (i=0; i<100; ++i) 53 | { 54 | save_state = malloc_get_state (); 55 | if (save_state == NULL) 56 | { 57 | merror ("malloc_get_state () failed."); 58 | break; 59 | } 60 | /*free (malloc (10)); This could change the top chunk! */ 61 | malloc_set_state (save_state); 62 | p1 = realloc (p1, i*4 + 4); 63 | if (p1 == NULL) 64 | merror ("realloc (i*4) failed."); 65 | free (save_state); 66 | } 67 | 68 | p1 = realloc (p1, 40); 69 | free (p2); 70 | p2 = malloc (10); 71 | if (p2 == NULL) 72 | merror ("malloc (10) failed."); 73 | free (p1); 74 | 75 | return errors != 0; 76 | } 77 | 78 | /* 79 | * Local variables: 80 | * c-basic-offset: 2 81 | * End: 82 | */ 83 | -------------------------------------------------------------------------------- /allocators/ptmalloc/ptmalloc3/COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2001-2006 Wolfram Gloger 2 | 3 | Permission to use, copy, modify, distribute, and sell this software 4 | and its documentation for any purpose is hereby granted without fee, 5 | provided that (i) the above copyright notices and this permission 6 | notice appear in all copies of the software and related documentation, 7 | and (ii) the name of Wolfram Gloger may not be used in any advertising 8 | or publicity relating to the software. 9 | 10 | THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 11 | EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 12 | WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | IN NO EVENT SHALL WOLFRAM GLOGER BE LIABLE FOR ANY SPECIAL, 15 | INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY 16 | DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 17 | WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY 18 | OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 19 | PERFORMANCE OF THIS SOFTWARE. 20 | -------------------------------------------------------------------------------- /allocators/ptmalloc/ptmalloc3/ChangeLog: -------------------------------------------------------------------------------- 1 | 2006-05-31 Wolfram Gloger 2 | 3 | * sysdeps/pthread/malloc-machine.h (mutex_unlock): Unlock needs 4 | full memory barrier (thanks Bart Robinson). 5 | 6 | 2006-03-31 Wolfram Gloger 7 | 8 | * ptmalloc3.c (public_iCALLOc, public_iCOMALLOc): New functions. 9 | 10 | 2006-03-30 Wolfram Gloger 11 | 12 | * malloc/malloc.c: Upgrade to version pre-2.8.4-29mar06. 13 | * malloc/malloc-private.h: New fields in malloc_state. 14 | 15 | 2004-03-29 Wolfram Gloger 16 | 17 | * malloc/malloc.c (mmap_alloc): Use page_align instead of 18 | granularity_align. 19 | (mmap_resize): Likewise. 20 | 21 | * malloc/ptmalloc3.c (ptmalloc_init): 22 | Add MALLOC_GRANULARITY_ and synonymous MALLOC_TOP_PAD_ environment 23 | parameters. 24 | 25 | 2006-03-25 Wolfram Gloger 26 | 27 | * malloc/malloc-private.h: New file. 28 | 29 | 2005-12-31 Wolfram Gloger 30 | 31 | * malloc/malloc.c: Imported from Doug Lea's malloc-2.8.3. 32 | * malloc/malloc.h-2.8.3.h: Likewise. 33 | * malloc/ptmalloc3.c: New file. 34 | -------------------------------------------------------------------------------- /allocators/ptmalloc/ptmalloc3/compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | case "$OSTYPE" in 4 | [Ll]inux*) 5 | echo "Compiling for Linux" 6 | gcc -pipe -march=pentium4 -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -D_REENTRANT=1 -shared malloc.c -o libptmalloc.so;; 7 | solaris) 8 | echo "Compiling for Solaris" 9 | #CC -xildoff -native -noex -xipo=2 -xO5 -mt -DNDEBUG -I. -I.. -D_REENTRANT=1 -G -PIC libptmalloc.cpp -o libptmalloc.so;; 10 | # g++ -pipe -DNDEBUG -I. -I.. -D_REENTRANT=1 -fPIC -shared libptmalloc.cpp -o libptmalloc.so;; 11 | gcc -DUSE_MALLOC_LOCK=1 -fPIC -pipe -mcpu=ultrasparc -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -c ptmalloc.c 12 | g++ -fPIC -pipe -mcpu=ultrasparc -O3 -finline-limit=5000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I../../heaplayers -D_REENTRANT=1 -shared libptmalloc.cpp ptmalloc.o -o libptmalloc.so;; 13 | # g++ -pipe -mcpu=ultrasparc -O3 -finline-limit=65000 -fkeep-inline-functions -finline-functions -ffast-math -fomit-frame-pointer -DNDEBUG -I. -I.. -D_REENTRANT=1 -shared libptmalloc.cpp -o libptmalloc.so;; 14 | *) 15 | echo "hmmm" 16 | esac 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /allocators/ptmalloc/ptmalloc3/lran2.h: -------------------------------------------------------------------------------- 1 | /* lran2.h 2 | * by Wolfram Gloger 1996. 3 | * 4 | * A small, portable pseudo-random number generator. 5 | */ 6 | 7 | #ifndef _LRAN2_H 8 | #define _LRAN2_H 9 | 10 | #define LRAN2_MAX 714025l /* constants for portable */ 11 | #define IA 1366l /* random number generator */ 12 | #define IC 150889l /* (see e.g. `Numerical Recipes') */ 13 | 14 | struct lran2_st { 15 | long x, y, v[97]; 16 | }; 17 | 18 | static void 19 | lran2_init(struct lran2_st* d, long seed) 20 | { 21 | long x; 22 | int j; 23 | 24 | x = (IC - seed) % LRAN2_MAX; 25 | if(x < 0) x = -x; 26 | for(j=0; j<97; j++) { 27 | x = (IA*x + IC) % LRAN2_MAX; 28 | d->v[j] = x; 29 | } 30 | d->x = (IA*x + IC) % LRAN2_MAX; 31 | d->y = d->x; 32 | } 33 | 34 | #ifdef __GNUC__ 35 | __inline__ 36 | #endif 37 | static long 38 | lran2(struct lran2_st* d) 39 | { 40 | int j = (d->y % 97); 41 | 42 | d->y = d->v[j]; 43 | d->x = (IA*d->x + IC) % LRAN2_MAX; 44 | d->v[j] = d->x; 45 | return d->y; 46 | } 47 | 48 | #undef IA 49 | #undef IC 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /allocators/ptmalloc/ptmalloc3/sysdeps/generic/atomic.h: -------------------------------------------------------------------------------- 1 | /* Empty placeholder */ 2 | -------------------------------------------------------------------------------- /allocators/ptmalloc/ptmalloc3/sysdeps/generic/thread-st.h: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id:$ 3 | * Generic version: no threads. 4 | * by Wolfram Gloger 2004 5 | */ 6 | 7 | #include 8 | 9 | struct thread_st { 10 | char *sp; /* stack pointer, can be 0 */ 11 | void (*func)(struct thread_st* st); /* must be set by user */ 12 | int id; 13 | int flags; 14 | struct user_data u; 15 | }; 16 | 17 | static void 18 | thread_init(void) 19 | { 20 | printf("No threads.\n"); 21 | } 22 | 23 | /* Create a thread. */ 24 | static int 25 | thread_create(struct thread_st *st) 26 | { 27 | st->flags = 0; 28 | st->id = 1; 29 | st->func(st); 30 | return 0; 31 | } 32 | 33 | /* Wait for one of several subthreads to finish. */ 34 | static void 35 | wait_for_thread(struct thread_st st[], int n_thr, 36 | int (*end_thr)(struct thread_st*)) 37 | { 38 | int i; 39 | for(i=0; i. 5 | 6 | Permission to use, copy, modify, distribute, and sell this software 7 | and its documentation for any purpose is hereby granted without fee, 8 | provided that (i) the above copyright notices and this permission 9 | notice appear in all copies of the software and related documentation, 10 | and (ii) the name of Wolfram Gloger may not be used in any advertising 11 | or publicity relating to the software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 14 | EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 15 | WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 16 | 17 | IN NO EVENT SHALL WOLFRAM GLOGER BE LIABLE FOR ANY SPECIAL, 18 | INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY 19 | DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 20 | WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY 21 | OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 22 | PERFORMANCE OF THIS SOFTWARE. 23 | */ 24 | 25 | #ifndef _SOLARIS_MALLOC_MACHINE_H 26 | #define _SOLARIS_MALLOC_MACHINE_H 27 | 28 | #include 29 | 30 | typedef thread_t thread_id; 31 | 32 | #define MUTEX_INITIALIZER { 0 } 33 | #define mutex_init(m) mutex_init(m, USYNC_THREAD, NULL) 34 | 35 | /* 36 | * Hack for thread-specific data on Solaris. We can't use thr_setspecific 37 | * because that function calls malloc() itself. 38 | */ 39 | typedef void *tsd_key_t[256]; 40 | #define tsd_key_create(key, destr) do { \ 41 | int i; \ 42 | for(i=0; i<256; i++) (*key)[i] = 0; \ 43 | } while(0) 44 | #define tsd_setspecific(key, data) (key[(unsigned)thr_self() % 256] = (data)) 45 | #define tsd_getspecific(key, vptr) (vptr = key[(unsigned)thr_self() % 256]) 46 | 47 | #define thread_atfork(prepare, parent, child) do {} while(0) 48 | 49 | #include 50 | 51 | #endif /* !defined(_SOLARIS_MALLOC_MACHINE_H) */ 52 | -------------------------------------------------------------------------------- /allocators/ptmalloc/ptmalloc3/sysdeps/solaris/thread-st.h: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id:$ 3 | * Solaris version 4 | * by Wolfram Gloger 2004 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #ifndef STACKSIZE 11 | #define STACKSIZE 32768 12 | #endif 13 | 14 | struct thread_st { 15 | char *sp; /* stack pointer, can be 0 */ 16 | void (*func)(struct thread_st* st); /* must be set by user */ 17 | thread_id id; 18 | int flags; 19 | struct user_data u; 20 | }; 21 | 22 | static void 23 | thread_init(void) 24 | { 25 | printf("Using Solaris threads.\n"); 26 | } 27 | 28 | static void * 29 | thread_wrapper(void *ptr) 30 | { 31 | struct thread_st *st = (struct thread_st*)ptr; 32 | 33 | /*printf("begin %p\n", st->sp);*/ 34 | st->func(st); 35 | /*printf("end %p\n", st->sp);*/ 36 | return NULL; 37 | } 38 | 39 | /* Create a thread. */ 40 | static int 41 | thread_create(struct thread_st *st) 42 | { 43 | st->flags = 0; 44 | if(!st->sp) 45 | st->sp = malloc(STACKSIZE); 46 | if(!st->sp) return -1; 47 | thr_create(st->sp, STACKSIZE, thread_wrapper, st, THR_NEW_LWP, &st->id); 48 | return 0; 49 | } 50 | 51 | /* Wait for one of several subthreads to finish. */ 52 | static void 53 | wait_for_thread(struct thread_st st[], int n_thr, 54 | int (*end_thr)(struct thread_st*)) 55 | { 56 | int i; 57 | thread_t id; 58 | 59 | thr_join(0, &id, NULL); 60 | for(i=0; i. 5 | 6 | Permission to use, copy, modify, distribute, and sell this software 7 | and its documentation for any purpose is hereby granted without fee, 8 | provided that (i) the above copyright notices and this permission 9 | notice appear in all copies of the software and related documentation, 10 | and (ii) the name of Wolfram Gloger may not be used in any advertising 11 | or publicity relating to the software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 14 | EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 15 | WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 16 | 17 | IN NO EVENT SHALL WOLFRAM GLOGER BE LIABLE FOR ANY SPECIAL, 18 | INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY 19 | DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 20 | WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY 21 | OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 22 | PERFORMANCE OF THIS SOFTWARE. 23 | */ 24 | 25 | #ifndef _SPROC_MALLOC_MACHINE_H 26 | #define _SPROC_MALLOC_MACHINE_H 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | typedef abilock_t mutex_t; 34 | 35 | #define MUTEX_INITIALIZER { 0 } 36 | #define mutex_init(m) init_lock(m) 37 | #define mutex_lock(m) (spin_lock(m), 0) 38 | #define mutex_trylock(m) acquire_lock(m) 39 | #define mutex_unlock(m) release_lock(m) 40 | 41 | typedef int tsd_key_t; 42 | int tsd_key_next; 43 | #define tsd_key_create(key, destr) ((*key) = tsd_key_next++) 44 | #define tsd_setspecific(key, data) (((void **)(&PRDA->usr_prda))[key] = data) 45 | #define tsd_getspecific(key, vptr) (vptr = ((void **)(&PRDA->usr_prda))[key]) 46 | 47 | #define thread_atfork(prepare, parent, child) do {} while(0) 48 | 49 | #include 50 | 51 | #endif /* !defined(_SPROC_MALLOC_MACHINE_H) */ 52 | -------------------------------------------------------------------------------- /allocators/ptmalloc/ptmalloc3/sysdeps/sproc/thread-st.h: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id:$ 3 | * sproc version 4 | * by Wolfram Gloger 2001, 2004, 2006 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #ifndef STACKSIZE 13 | #define STACKSIZE 32768 14 | #endif 15 | 16 | struct thread_st { 17 | char *sp; /* stack pointer, can be 0 */ 18 | void (*func)(struct thread_st* st); /* must be set by user */ 19 | int id; 20 | int flags; 21 | struct user_data u; 22 | }; 23 | 24 | static void 25 | thread_init(void) 26 | { 27 | printf("Using sproc() threads.\n"); 28 | } 29 | 30 | static void 31 | thread_wrapper(void *ptr, size_t stack_len) 32 | { 33 | struct thread_st *st = (struct thread_st*)ptr; 34 | 35 | /*printf("begin %p\n", st->sp);*/ 36 | st->func(st); 37 | /*printf("end %p\n", st->sp);*/ 38 | } 39 | 40 | /* Create a thread. */ 41 | static int 42 | thread_create(struct thread_st *st) 43 | { 44 | st->flags = 0; 45 | if(!st->sp) 46 | st->sp = malloc(STACKSIZE); 47 | if(!st->sp) return -1; 48 | st->id = sprocsp(thread_wrapper, PR_SALL, st, st->sp+STACKSIZE, STACKSIZE); 49 | if(st->id < 0) { 50 | return -1; 51 | } 52 | return 0; 53 | } 54 | 55 | /* Wait for one of several subthreads to finish. */ 56 | static void 57 | wait_for_thread(struct thread_st st[], int n_thr, 58 | int (*end_thr)(struct thread_st*)) 59 | { 60 | int i; 61 | int id; 62 | 63 | int status = 0; 64 | id = wait(&status); 65 | if(status != 0) { 66 | if(WIFSIGNALED(status)) 67 | printf("thread %id terminated by signal %d\n", 68 | id, WTERMSIG(status)); 69 | else 70 | printf("thread %id exited with status %d\n", 71 | id, WEXITSTATUS(status)); 72 | } 73 | for(i=0; i 7 | * 8 | * 02/06/02 find_next_bit() and find_first_bit() added from Erich Focht's ia64 9 | * O(1) scheduler patch 10 | */ 11 | 12 | /** 13 | * __change_bit - Toggle a bit in memory 14 | * @nr: the bit to set 15 | * @addr: the address to start counting from 16 | * 17 | * Unlike change_bit(), this function is non-atomic and may be reordered. 18 | * If it's called on the same region of memory simultaneously, the effect 19 | * may be that only one operation succeeds. 20 | */ 21 | static __inline__ void 22 | __change_bit (int nr, volatile void *addr) 23 | { 24 | *((unsigned int *) addr + (nr >> 5)) ^= (1 << (nr & 31)); 25 | } 26 | 27 | /* 28 | * WARNING: non atomic version. 29 | */ 30 | static __inline__ int 31 | __test_and_change_bit (int nr, void *addr) 32 | { 33 | unsigned int old, bit = (1 << (nr & 31)); 34 | unsigned int *m = (unsigned int *) addr + (nr >> 5); 35 | 36 | old = *m; 37 | *m = old ^ bit; 38 | return (old & bit) != 0; 39 | } 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /allocators/streamflow/streamflow/include-x86_64/atomic.h: -------------------------------------------------------------------------------- 1 | #ifndef __SYNCHRO_ATOMIC_H__ 2 | #define __SYNCHRO_ATOMIC_H__ 3 | 4 | #define mb() asm volatile ("sync" : : : "memory") 5 | #define LOCK_PREFIX "lock ; " 6 | 7 | static inline unsigned long fetch_and_store(volatile unsigned int *address, unsigned int value) 8 | { 9 | asm volatile("xchgl %k0,%1" 10 | : "=r" (value) 11 | : "m" (*address), "0" (value) 12 | : "memory"); 13 | 14 | return value; 15 | } 16 | 17 | static inline int atmc_fetch_and_add(volatile unsigned int *address, int value) 18 | { 19 | int prev = value; 20 | 21 | asm volatile( 22 | LOCK_PREFIX "xaddl %0, %1" 23 | : "+r" (value), "+m" (*address) 24 | : : "memory"); 25 | 26 | return prev + value; 27 | } 28 | 29 | static inline void atmc_add32(volatile unsigned int* address, int value) 30 | { 31 | asm volatile( 32 | LOCK_PREFIX "addl %1,%0" 33 | : "=m" (*address) 34 | : "ir" (value), "m" (*address)); 35 | } 36 | 37 | static inline void atmc_add64(volatile unsigned long long* address, unsigned long long value) 38 | { 39 | asm volatile( 40 | LOCK_PREFIX "addq %1,%0" 41 | : "=m" (*address) 42 | : "ir" (value), "m" (*address)); 43 | } 44 | 45 | static inline unsigned int compare_and_swap32(volatile unsigned int *address, unsigned int old_value, unsigned int new_value) 46 | { 47 | unsigned long prev = 0; 48 | 49 | asm volatile(LOCK_PREFIX "cmpxchgl %k1,%2" 50 | : "=a"(prev) 51 | : "r"(new_value), "m"(*address), "0"(old_value) 52 | : "memory"); 53 | 54 | return prev == old_value; 55 | } 56 | 57 | static inline unsigned int compare_and_swap64(volatile unsigned long long *address, unsigned long old_value, unsigned long new_value) 58 | { 59 | unsigned long prev = 0; 60 | 61 | asm volatile(LOCK_PREFIX "cmpxchgq %1,%2" 62 | : "=a"(prev) 63 | : "r"(new_value), "m"(*address), "0"(old_value) 64 | : "memory"); 65 | 66 | return prev == old_value; 67 | } 68 | 69 | static inline unsigned long compare_and_swap_ptr(volatile void *address, void* old_ptr, void* new_ptr) 70 | { 71 | return compare_and_swap64((volatile unsigned long long *)address, (unsigned long)old_ptr, (unsigned long)new_ptr); 72 | } 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /allocators/streamflow/streamflow/include-x86_64/bitops.h: -------------------------------------------------------------------------------- 1 | #ifndef _X86_64_BITOPS_H 2 | #define _X86_64_BITOPS_H 3 | 4 | /* 5 | * Copyright 1992, Linus Torvalds. 6 | */ 7 | 8 | #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1) 9 | /* Technically wrong, but this avoids compilation errors on some gcc 10 | versions. */ 11 | #define ADDR "=m" (*(volatile long *) addr) 12 | #else 13 | #define ADDR "+m" (*(volatile long *) addr) 14 | #endif 15 | 16 | /** 17 | * __change_bit - Toggle a bit in memory 18 | * @nr: the bit to change 19 | * @addr: the address to start counting from 20 | * 21 | * Unlike change_bit(), this function is non-atomic and may be reordered. 22 | * If it's called on the same region of memory simultaneously, the effect 23 | * may be that only one operation succeeds. 24 | */ 25 | static __inline__ void __change_bit(int nr, volatile void * addr) 26 | { 27 | __asm__ __volatile__( 28 | "btcl %1,%0" 29 | :ADDR 30 | :"dIr" (nr)); 31 | } 32 | 33 | /* WARNING: non atomic and it can be reordered! */ 34 | static __inline__ int __test_and_change_bit(int nr, volatile void * addr) 35 | { 36 | int oldbit; 37 | 38 | __asm__ __volatile__( 39 | "btcl %2,%1\n\tsbbl %0,%0" 40 | :"=r" (oldbit),ADDR 41 | :"dIr" (nr) : "memory"); 42 | return oldbit; 43 | } 44 | 45 | #endif /* _X86_64_BITOPS_H */ 46 | 47 | -------------------------------------------------------------------------------- /allocators/streamflow/streamflow/larson-30_7-8: -------------------------------------------------------------------------------- 1 | 30 2 | 7 8 3 | 1 1 4 | 10000 5 | 1000 6 | 1 7 | -------------------------------------------------------------------------------- /allocators/streamflow/streamflow/lock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Scott Schneider, Christos Antonopoulos 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef __LOCK_H_ 20 | #define __LOCK_H_ 21 | 22 | #include "atomic.h" 23 | 24 | typedef volatile unsigned int lock_t; 25 | 26 | static void spin_init(lock_t *lock); 27 | static void spin_lock(lock_t *lock); 28 | static void spin_unlock(lock_t *lock); 29 | 30 | typedef struct { 31 | unsigned long num_threads; 32 | volatile unsigned long arrived; 33 | volatile unsigned long global_sense; 34 | } barrier_t; 35 | 36 | static void bar_init(barrier_t *barr, unsigned long num_threads); 37 | static void bar(barrier_t *barr); 38 | 39 | static inline void spin_init(lock_t* lock) 40 | { 41 | *(lock) = 0; 42 | } 43 | 44 | static inline void spin_lock(lock_t* lock) 45 | { 46 | while (fetch_and_store((volatile unsigned int *)(lock), 1)) { 47 | while(*(lock)); 48 | } 49 | } 50 | 51 | static inline void spin_unlock(lock_t* lock) 52 | { 53 | *(lock) = 0; 54 | } 55 | 56 | static inline void bar_init(barrier_t* barr, unsigned long num_threads) 57 | { 58 | barr->global_sense = 0; 59 | barr->arrived = 0; 60 | barr->num_threads = num_threads; 61 | } 62 | 63 | static inline void bar(barrier_t* barr) 64 | { 65 | unsigned long local_sense, my_num; 66 | 67 | local_sense = barr->global_sense; 68 | my_num = fetch_and_add(&(barr->arrived), 1); 69 | if (my_num == barr->num_threads - 1) { 70 | barr->arrived = 0; 71 | barr->global_sense = !barr->global_sense; 72 | } 73 | else { 74 | while(local_sense == barr->global_sense); 75 | } 76 | } 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /allocators/streamflow/streamflow/malloc_new.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Scott Schneider, Christos Antonopoulos 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #include 20 | 21 | extern "C" { 22 | void* malloc(size_t); 23 | void free(void*); 24 | } 25 | 26 | void* operator new(size_t sz) throw (std::bad_alloc) 27 | { 28 | return malloc(sz); 29 | } 30 | 31 | void * operator new(size_t sz, const std::nothrow_t&) throw() 32 | { 33 | return malloc(sz); 34 | } 35 | 36 | void operator delete(void * ptr) 37 | { 38 | free(ptr); 39 | } 40 | 41 | void* operator new[](size_t sz) throw (std::bad_alloc) 42 | { 43 | return malloc(sz); 44 | } 45 | 46 | void * operator new[](size_t sz, const std::nothrow_t&) throw() 47 | { 48 | return malloc(sz); 49 | } 50 | 51 | void operator delete[](void * ptr) 52 | { 53 | free(ptr); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/.deps/markidle_unittest-testutil.Po: -------------------------------------------------------------------------------- 1 | markidle_unittest-testutil.o markidle_unittest-testutil.o: \ 2 | src/tests/testutil.cc src/config.h /usr/include/stdlib.h \ 3 | /usr/include/features.h /usr/include/sys/cdefs.h \ 4 | /usr/include/gnu/stubs.h \ 5 | /usr/local/lib/gcc/i686-pc-linux-gnu/4.0.2/include/stddef.h \ 6 | /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \ 7 | /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \ 8 | /usr/include/sys/types.h /usr/include/bits/types.h \ 9 | /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ 10 | /usr/include/time.h /usr/include/sys/select.h \ 11 | /usr/include/bits/select.h /usr/include/bits/sigset.h \ 12 | /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ 13 | /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ 14 | /usr/include/alloca.h src/tests/testutil.h /usr/include/pthread.h \ 15 | /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ 16 | /usr/include/bits/sigthread.h 17 | 18 | src/config.h: 19 | 20 | /usr/include/stdlib.h: 21 | 22 | /usr/include/features.h: 23 | 24 | /usr/include/sys/cdefs.h: 25 | 26 | /usr/include/gnu/stubs.h: 27 | 28 | /usr/local/lib/gcc/i686-pc-linux-gnu/4.0.2/include/stddef.h: 29 | 30 | /usr/include/bits/waitflags.h: 31 | 32 | /usr/include/bits/waitstatus.h: 33 | 34 | /usr/include/endian.h: 35 | 36 | /usr/include/bits/endian.h: 37 | 38 | /usr/include/xlocale.h: 39 | 40 | /usr/include/sys/types.h: 41 | 42 | /usr/include/bits/types.h: 43 | 44 | /usr/include/bits/wordsize.h: 45 | 46 | /usr/include/bits/typesizes.h: 47 | 48 | /usr/include/time.h: 49 | 50 | /usr/include/sys/select.h: 51 | 52 | /usr/include/bits/select.h: 53 | 54 | /usr/include/bits/sigset.h: 55 | 56 | /usr/include/bits/time.h: 57 | 58 | /usr/include/sys/sysmacros.h: 59 | 60 | /usr/include/bits/pthreadtypes.h: 61 | 62 | /usr/include/bits/sched.h: 63 | 64 | /usr/include/alloca.h: 65 | 66 | src/tests/testutil.h: 67 | 68 | /usr/include/pthread.h: 69 | 70 | /usr/include/sched.h: 71 | 72 | /usr/include/signal.h: 73 | 74 | /usr/include/bits/initspin.h: 75 | 76 | /usr/include/bits/sigthread.h: 77 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/.deps/mutex.Plo: -------------------------------------------------------------------------------- 1 | mutex.lo mutex.o: src/base/mutex.cc src/config.h src/base/mutex.h \ 2 | /usr/include/pthread.h /usr/include/features.h /usr/include/sys/cdefs.h \ 3 | /usr/include/gnu/stubs.h /usr/include/sched.h /usr/include/bits/types.h \ 4 | /usr/include/bits/wordsize.h \ 5 | /usr/local/lib/gcc/i686-pc-linux-gnu/4.0.2/include/stddef.h \ 6 | /usr/include/bits/typesizes.h /usr/include/time.h \ 7 | /usr/include/bits/sched.h /usr/include/bits/time.h \ 8 | /usr/include/xlocale.h /usr/include/signal.h /usr/include/bits/sigset.h \ 9 | /usr/include/bits/pthreadtypes.h /usr/include/bits/initspin.h \ 10 | /usr/include/bits/sigthread.h /usr/include/stdlib.h \ 11 | /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \ 12 | /usr/include/endian.h /usr/include/bits/endian.h \ 13 | /usr/include/sys/types.h /usr/include/sys/select.h \ 14 | /usr/include/bits/select.h /usr/include/sys/sysmacros.h \ 15 | /usr/include/alloca.h 16 | 17 | src/config.h: 18 | 19 | src/base/mutex.h: 20 | 21 | /usr/include/pthread.h: 22 | 23 | /usr/include/features.h: 24 | 25 | /usr/include/sys/cdefs.h: 26 | 27 | /usr/include/gnu/stubs.h: 28 | 29 | /usr/include/sched.h: 30 | 31 | /usr/include/bits/types.h: 32 | 33 | /usr/include/bits/wordsize.h: 34 | 35 | /usr/local/lib/gcc/i686-pc-linux-gnu/4.0.2/include/stddef.h: 36 | 37 | /usr/include/bits/typesizes.h: 38 | 39 | /usr/include/time.h: 40 | 41 | /usr/include/bits/sched.h: 42 | 43 | /usr/include/bits/time.h: 44 | 45 | /usr/include/xlocale.h: 46 | 47 | /usr/include/signal.h: 48 | 49 | /usr/include/bits/sigset.h: 50 | 51 | /usr/include/bits/pthreadtypes.h: 52 | 53 | /usr/include/bits/initspin.h: 54 | 55 | /usr/include/bits/sigthread.h: 56 | 57 | /usr/include/stdlib.h: 58 | 59 | /usr/include/bits/waitflags.h: 60 | 61 | /usr/include/bits/waitstatus.h: 62 | 63 | /usr/include/endian.h: 64 | 65 | /usr/include/bits/endian.h: 66 | 67 | /usr/include/sys/types.h: 68 | 69 | /usr/include/sys/select.h: 70 | 71 | /usr/include/bits/select.h: 72 | 73 | /usr/include/sys/sysmacros.h: 74 | 75 | /usr/include/alloca.h: 76 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/.deps/stacktrace.Plo: -------------------------------------------------------------------------------- 1 | stacktrace.lo stacktrace.o: src/stacktrace.cc src/config.h \ 2 | src/stacktrace_x86-inl.h /usr/include/stdint.h /usr/include/features.h \ 3 | /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ 4 | /usr/include/bits/wchar.h /usr/include/bits/wordsize.h \ 5 | /usr/include/stdlib.h \ 6 | /usr/local/lib/gcc/i686-pc-linux-gnu/4.0.2/include/stddef.h \ 7 | /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \ 8 | /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \ 9 | /usr/include/sys/types.h /usr/include/bits/types.h \ 10 | /usr/include/bits/typesizes.h /usr/include/time.h \ 11 | /usr/include/sys/select.h /usr/include/bits/select.h \ 12 | /usr/include/bits/sigset.h /usr/include/bits/time.h \ 13 | /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ 14 | /usr/include/bits/sched.h /usr/include/alloca.h src/google/stacktrace.h 15 | 16 | src/config.h: 17 | 18 | src/stacktrace_x86-inl.h: 19 | 20 | /usr/include/stdint.h: 21 | 22 | /usr/include/features.h: 23 | 24 | /usr/include/sys/cdefs.h: 25 | 26 | /usr/include/gnu/stubs.h: 27 | 28 | /usr/include/bits/wchar.h: 29 | 30 | /usr/include/bits/wordsize.h: 31 | 32 | /usr/include/stdlib.h: 33 | 34 | /usr/local/lib/gcc/i686-pc-linux-gnu/4.0.2/include/stddef.h: 35 | 36 | /usr/include/bits/waitflags.h: 37 | 38 | /usr/include/bits/waitstatus.h: 39 | 40 | /usr/include/endian.h: 41 | 42 | /usr/include/bits/endian.h: 43 | 44 | /usr/include/xlocale.h: 45 | 46 | /usr/include/sys/types.h: 47 | 48 | /usr/include/bits/types.h: 49 | 50 | /usr/include/bits/typesizes.h: 51 | 52 | /usr/include/time.h: 53 | 54 | /usr/include/sys/select.h: 55 | 56 | /usr/include/bits/select.h: 57 | 58 | /usr/include/bits/sigset.h: 59 | 60 | /usr/include/bits/time.h: 61 | 62 | /usr/include/sys/sysmacros.h: 63 | 64 | /usr/include/bits/pthreadtypes.h: 65 | 66 | /usr/include/bits/sched.h: 67 | 68 | /usr/include/alloca.h: 69 | 70 | src/google/stacktrace.h: 71 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/.deps/thread_dealloc_unittest-testutil.Po: -------------------------------------------------------------------------------- 1 | thread_dealloc_unittest-testutil.o thread_dealloc_unittest-testutil.o: \ 2 | src/tests/testutil.cc src/config.h /usr/include/stdlib.h \ 3 | /usr/include/features.h /usr/include/sys/cdefs.h \ 4 | /usr/include/gnu/stubs.h \ 5 | /usr/local/lib/gcc/i686-pc-linux-gnu/4.0.2/include/stddef.h \ 6 | /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \ 7 | /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \ 8 | /usr/include/sys/types.h /usr/include/bits/types.h \ 9 | /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ 10 | /usr/include/time.h /usr/include/sys/select.h \ 11 | /usr/include/bits/select.h /usr/include/bits/sigset.h \ 12 | /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ 13 | /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ 14 | /usr/include/alloca.h src/tests/testutil.h /usr/include/pthread.h \ 15 | /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ 16 | /usr/include/bits/sigthread.h 17 | 18 | src/config.h: 19 | 20 | /usr/include/stdlib.h: 21 | 22 | /usr/include/features.h: 23 | 24 | /usr/include/sys/cdefs.h: 25 | 26 | /usr/include/gnu/stubs.h: 27 | 28 | /usr/local/lib/gcc/i686-pc-linux-gnu/4.0.2/include/stddef.h: 29 | 30 | /usr/include/bits/waitflags.h: 31 | 32 | /usr/include/bits/waitstatus.h: 33 | 34 | /usr/include/endian.h: 35 | 36 | /usr/include/bits/endian.h: 37 | 38 | /usr/include/xlocale.h: 39 | 40 | /usr/include/sys/types.h: 41 | 42 | /usr/include/bits/types.h: 43 | 44 | /usr/include/bits/wordsize.h: 45 | 46 | /usr/include/bits/typesizes.h: 47 | 48 | /usr/include/time.h: 49 | 50 | /usr/include/sys/select.h: 51 | 52 | /usr/include/bits/select.h: 53 | 54 | /usr/include/bits/sigset.h: 55 | 56 | /usr/include/bits/time.h: 57 | 58 | /usr/include/sys/sysmacros.h: 59 | 60 | /usr/include/bits/pthreadtypes.h: 61 | 62 | /usr/include/bits/sched.h: 63 | 64 | /usr/include/alloca.h: 65 | 66 | src/tests/testutil.h: 67 | 68 | /usr/include/pthread.h: 69 | 70 | /usr/include/sched.h: 71 | 72 | /usr/include/signal.h: 73 | 74 | /usr/include/bits/initspin.h: 75 | 76 | /usr/include/bits/sigthread.h: 77 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/.deps/thread_lister.Plo: -------------------------------------------------------------------------------- 1 | thread_lister.lo thread_lister.o: src/base/thread_lister.c \ 2 | /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ 3 | /usr/include/gnu/stubs.h \ 4 | /usr/local/lib/gcc/i686-pc-linux-gnu/4.0.2/include/stddef.h \ 5 | /usr/include/bits/types.h /usr/include/bits/wordsize.h \ 6 | /usr/include/bits/typesizes.h /usr/include/libio.h \ 7 | /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ 8 | /usr/include/gconv.h \ 9 | /usr/local/lib/gcc/i686-pc-linux-gnu/4.0.2/include/stdarg.h \ 10 | /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ 11 | /usr/include/bits/stdio.h /usr/include/sys/prctl.h \ 12 | /usr/include/linux/prctl.h src/base/thread_lister.h \ 13 | /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ 14 | /usr/include/bits/endian.h /usr/include/sys/select.h \ 15 | /usr/include/bits/select.h /usr/include/bits/sigset.h \ 16 | /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ 17 | /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ 18 | src/base/linuxthreads.h 19 | 20 | /usr/include/stdio.h: 21 | 22 | /usr/include/features.h: 23 | 24 | /usr/include/sys/cdefs.h: 25 | 26 | /usr/include/gnu/stubs.h: 27 | 28 | /usr/local/lib/gcc/i686-pc-linux-gnu/4.0.2/include/stddef.h: 29 | 30 | /usr/include/bits/types.h: 31 | 32 | /usr/include/bits/wordsize.h: 33 | 34 | /usr/include/bits/typesizes.h: 35 | 36 | /usr/include/libio.h: 37 | 38 | /usr/include/_G_config.h: 39 | 40 | /usr/include/wchar.h: 41 | 42 | /usr/include/bits/wchar.h: 43 | 44 | /usr/include/gconv.h: 45 | 46 | /usr/local/lib/gcc/i686-pc-linux-gnu/4.0.2/include/stdarg.h: 47 | 48 | /usr/include/bits/stdio_lim.h: 49 | 50 | /usr/include/bits/sys_errlist.h: 51 | 52 | /usr/include/bits/stdio.h: 53 | 54 | /usr/include/sys/prctl.h: 55 | 56 | /usr/include/linux/prctl.h: 57 | 58 | src/base/thread_lister.h: 59 | 60 | /usr/include/sys/types.h: 61 | 62 | /usr/include/time.h: 63 | 64 | /usr/include/endian.h: 65 | 66 | /usr/include/bits/endian.h: 67 | 68 | /usr/include/sys/select.h: 69 | 70 | /usr/include/bits/select.h: 71 | 72 | /usr/include/bits/sigset.h: 73 | 74 | /usr/include/bits/time.h: 75 | 76 | /usr/include/sys/sysmacros.h: 77 | 78 | /usr/include/bits/pthreadtypes.h: 79 | 80 | /usr/include/bits/sched.h: 81 | 82 | src/base/linuxthreads.h: 83 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/AUTHORS: -------------------------------------------------------------------------------- 1 | opensource@google.com 2 | 3 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/NEWS -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/TODO: -------------------------------------------------------------------------------- 1 | HEAP PROFILER 2 | 3 | 1) Fix heap profiling under all STLs 4 | * Find out how to force non-glibc STL libraries to call new() and 5 | delete() for every allocation / deallocation. 6 | * Make heap profiler ignore STL-internal allocations for those 7 | libraries under which we cannot profile accurately, so we only 8 | see object-level leaks. 9 | 2) Remove dependency on tcmalloc? 10 | 3) Port to non-linux O/Ses (right now code uses /proc for library info) 11 | 4) Port to non-x86 architectures (locking code in spinlock is x86-specific) 12 | 5) Port to C? 13 | 6) Figure out how to get setenv() to work properly before main() in 14 | shared libaries, and get rid of the profile-naming hack once we 15 | do. (See HeapProfiler::Init().) 16 | 17 | 18 | HEAP CHECKER 19 | 20 | 1) Remove requirement that the heap-checker must be linked last into 21 | an application (hard! -- it needs its global constructor to run 22 | first) 23 | 24 | TCMALLOC 25 | 26 | 1) Implement mallinfo/mallopt 27 | 2) Have tcmalloc work correctly when libpthread is not linked in 28 | (currently working for glibc, could use other libc's too) 29 | 3) Return memory to the system when requirements drop 30 | 4) Explore coloring allocated objects to avoid cache conflicts 31 | 5) Explore biasing reclamation to larger addresses 32 | 6) Add contention stats to a synchronization.cc (can do spinlocks, 33 | but threads? -- may have to provide our own thread implementation) 34 | 35 | CPU PROFILER 36 | 37 | 1) Figure out how to get setenv() to work properly before main() in 38 | shared libaries(), and get rid of the profile-naming hack once we 39 | do. (See Profiler::GetUniquePathFromEnv().) 40 | 2) Resolve crashing problems on x86_64 (see README) 41 | 42 | STACKTRACE 43 | 44 | 1) Document and advertise libstacktrace 45 | 2) Remove dependency on linux/x86 46 | 47 | --- 48 | 4 April 2007 49 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/heap-example1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/heap-example1.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Google Performance Tools 5 | 6 | 7 | 8 | 14 | 15 |
16 | Last modified: Wed Mar 21 22:46:51 PDT 2007 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/overview.dot: -------------------------------------------------------------------------------- 1 | digraph Overview { 2 | node [shape = box] 3 | 4 | {rank=same 5 | T1 [label="Thread Cache"] 6 | Tsep [label="...", shape=plaintext] 7 | Tn [label="Thread Cache"] 8 | T1 -> Tsep -> Tn [style=invis] 9 | } 10 | 11 | C [label="Central\nHeap"] 12 | T1 -> C [dir=both] 13 | Tn -> C [dir=both] 14 | 15 | } 16 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/overview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/overview.gif -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/pageheap.dot: -------------------------------------------------------------------------------- 1 | digraph PageHeap { 2 | rankdir=LR 3 | node [shape=box, width=0.3, height=0.3] 4 | nodesep=.05 5 | 6 | heap [shape=record, height=3, label="1 page|2 pages|3 pages|...|255 pages|rest"] 7 | O0 [shape=record, label=""] 8 | O1 [shape=record, label=""] 9 | O2 [shape=record, label="{|}"] 10 | O3 [shape=record, label="{|}"] 11 | O4 [shape=record, label="{||}"] 12 | O5 [shape=record, label="{||}"] 13 | O6 [shape=record, label="{|...|}"] 14 | O7 [shape=record, label="{|...|}"] 15 | O8 [shape=record, label="{|.....|}"] 16 | O9 [shape=record, label="{|.....|}"] 17 | sep1 [shape=plaintext, label="..."] 18 | sep2 [shape=plaintext, label="..."] 19 | sep3 [shape=plaintext, label="..."] 20 | sep4 [shape=plaintext, label="..."] 21 | sep5 [shape=plaintext, label="..."] 22 | 23 | heap:f0 -> O0 -> O1 -> sep1 24 | heap:f1 -> O2 -> O3 -> sep2 25 | heap:f2 -> O4 -> O5 -> sep3 26 | heap:f255 -> O6 -> O7 -> sep4 27 | heap:frest -> O8 -> O9 -> sep5 28 | 29 | } 30 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/pageheap.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/pageheap.gif -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/pprof-test-big.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/pprof-test-big.gif -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/pprof-test.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/pprof-test.gif -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/pprof-vsnprintf-big.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/pprof-vsnprintf-big.gif -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/pprof-vsnprintf.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/pprof-vsnprintf.gif -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/spanmap.dot: -------------------------------------------------------------------------------- 1 | digraph SpanMap { 2 | node [shape=box, width=0.3, height=0.3] 3 | nodesep=.05 4 | 5 | map [shape=record, width=6, label="||||||||||"] 6 | S0 [label="a"] 7 | S1 [label="b"] 8 | S2 [label="c"] 9 | S3 [label="d"] 10 | map:f0 -> S0 11 | map:f1 -> S0 12 | map:f2 -> S1 13 | map:f3 -> S2 14 | map:f4 -> S2 15 | map:f5 -> S2 16 | map:f6 -> S2 17 | map:f7 -> S2 18 | map:f8 -> S3 19 | map:f9 -> S3 20 | map:f10 -> S3 21 | 22 | } 23 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/spanmap.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/spanmap.gif -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.1024.bytes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.1024.bytes.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.128.bytes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.128.bytes.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.131072.bytes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.131072.bytes.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.16384.bytes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.16384.bytes.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.2048.bytes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.2048.bytes.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.256.bytes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.256.bytes.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.32768.bytes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.32768.bytes.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.4096.bytes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.4096.bytes.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.512.bytes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.512.bytes.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.64.bytes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.64.bytes.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.65536.bytes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.65536.bytes.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.8192.bytes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspercpusec.vs.threads.8192.bytes.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.1.threads.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.1.threads.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.12.threads.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.12.threads.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.16.threads.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.16.threads.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.2.threads.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.2.threads.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.20.threads.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.20.threads.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.3.threads.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.3.threads.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.4.threads.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.4.threads.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.5.threads.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.5.threads.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.8.threads.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/tcmalloc-opspersec.vs.size.8.threads.png -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/threadheap.dot: -------------------------------------------------------------------------------- 1 | digraph ThreadHeap { 2 | rankdir=LR 3 | node [shape=box, width=0.3, height=0.3] 4 | nodesep=.05 5 | 6 | heap [shape=record, height=2, label="class 0|class 1|class 2|..."] 7 | O0 [label=""] 8 | O1 [label=""] 9 | O2 [label=""] 10 | O3 [label=""] 11 | O4 [label=""] 12 | O5 [label=""] 13 | sep1 [shape=plaintext, label="..."] 14 | sep2 [shape=plaintext, label="..."] 15 | sep3 [shape=plaintext, label="..."] 16 | 17 | heap:f0 -> O0 -> O1 -> sep1 18 | heap:f1 -> O2 -> O3 -> sep2 19 | heap:f2 -> O4 -> O5 -> sep3 20 | 21 | } 22 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/doc/threadheap.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emeryberger/Malloc-Implementations/17e52035d91f9f2e52e3303c8872ee29f5b5a7c5/allocators/tcmalloc/google-perftools-0.91/doc/threadheap.gif -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Public domain 6 | 7 | errstatus=0 8 | dirmode="" 9 | 10 | usage="\ 11 | Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." 12 | 13 | # process command line arguments 14 | while test $# -gt 0 ; do 15 | case "${1}" in 16 | -h | --help | --h* ) # -h for help 17 | echo "${usage}" 1>&2; exit 0 ;; 18 | -m ) # -m PERM arg 19 | shift 20 | test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } 21 | dirmode="${1}" 22 | shift ;; 23 | -- ) shift; break ;; # stop option processing 24 | -* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option 25 | * ) break ;; # first non-opt arg 26 | esac 27 | done 28 | 29 | for file 30 | do 31 | if test -d "$file"; then 32 | shift 33 | else 34 | break 35 | fi 36 | done 37 | 38 | case $# in 39 | 0) exit 0 ;; 40 | esac 41 | 42 | case $dirmode in 43 | '') 44 | if mkdir -p -- . 2>/dev/null; then 45 | echo "mkdir -p -- $*" 46 | exec mkdir -p -- "$@" 47 | fi ;; 48 | *) 49 | if mkdir -m "$dirmode" -p -- . 2>/dev/null; then 50 | echo "mkdir -m $dirmode -p -- $*" 51 | exec mkdir -m "$dirmode" -p -- "$@" 52 | fi ;; 53 | esac 54 | 55 | for file 56 | do 57 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 58 | shift 59 | 60 | pathcomp= 61 | for d 62 | do 63 | pathcomp="$pathcomp$d" 64 | case "$pathcomp" in 65 | -* ) pathcomp=./$pathcomp ;; 66 | esac 67 | 68 | if test ! -d "$pathcomp"; then 69 | echo "mkdir $pathcomp" 70 | 71 | mkdir "$pathcomp" || lasterr=$? 72 | 73 | if test ! -d "$pathcomp"; then 74 | errstatus=$lasterr 75 | else 76 | if test ! -z "$dirmode"; then 77 | echo "chmod $dirmode $pathcomp" 78 | 79 | lasterr="" 80 | chmod "$dirmode" "$pathcomp" || lasterr=$? 81 | 82 | if test ! -z "$lasterr"; then 83 | errstatus=$lasterr 84 | fi 85 | fi 86 | fi 87 | fi 88 | 89 | pathcomp="$pathcomp/" 90 | done 91 | done 92 | 93 | exit $errstatus 94 | 95 | # Local Variables: 96 | # mode: shell-script 97 | # sh-indentation: 3 98 | # End: 99 | # mkinstalldirs ends here 100 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/packages/deb/README: -------------------------------------------------------------------------------- 1 | The list of files here isn't complete. For a step-by-step guide on 2 | how to set this package up correctly, check out 3 | http://www.debian.org/doc/maint-guide/ 4 | 5 | Most of the files that are in this directory are boilerplate. 6 | However, you may need to change the list of binary-arch dependencies 7 | in 'rules'. 8 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/packages/deb/compat: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/packages/deb/control: -------------------------------------------------------------------------------- 1 | Source: google-perftools 2 | Priority: optional 3 | Maintainer: Google Inc. 4 | Build-Depends: debhelper (>= 4.0.0), binutils 5 | Standards-Version: 3.6.1 6 | 7 | Package: libgoogle-perftools-dev 8 | Section: libdevel 9 | Architecture: any 10 | Depends: libgoogle-perftools0 (= ${Source-Version}) 11 | Description: libraries for CPU and heap analysis, plus an efficient thread-caching malloc 12 | The google-perftools package contains some utilities to improve and 13 | analyze the performance of C++ programs. This includes an optimized 14 | thread-caching malloc() and cpu and heap profiling utilities. The 15 | devel package contains static and debug libraries and header files 16 | for developing applications that use the google-perftools package. 17 | 18 | Package: libgoogle-perftools0 19 | Section: libs 20 | Architecture: any 21 | Depends: ${shlibs:Depends} 22 | Description: libraries for CPU and heap analysis, plus an efficient thread-caching malloc 23 | The google-perftools package contains some utilities to improve and 24 | analyze the performance of C++ programs. This includes an optimized 25 | thread-caching malloc() and cpu and heap profiling utilities. 26 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/packages/deb/copyright: -------------------------------------------------------------------------------- 1 | This package was debianized by Google Inc. on 2 | 15 February 2005. 3 | 4 | It was downloaded from http://code.google.com/ 5 | 6 | Upstream Author: opensource@google.com 7 | 8 | Copyright (c) 2005, Google Inc. 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are 13 | met: 14 | 15 | * Redistributions of source code must retain the above copyright 16 | notice, this list of conditions and the following disclaimer. 17 | * Redistributions in binary form must reproduce the above 18 | copyright notice, this list of conditions and the following disclaimer 19 | in the documentation and/or other materials provided with the 20 | distribution. 21 | * Neither the name of Google Inc. nor the names of its 22 | contributors may be used to endorse or promote products derived from 23 | this software without specific prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/packages/deb/docs: -------------------------------------------------------------------------------- 1 | AUTHORS 2 | COPYING 3 | ChangeLog 4 | INSTALL 5 | NEWS 6 | README 7 | TODO 8 | doc/cpuprofile.html 9 | doc/designstyle.css 10 | doc/heap-example1.png 11 | doc/heap_checker.html 12 | doc/heapprofile.html 13 | doc/index.html 14 | doc/overview.gif 15 | doc/pageheap.gif 16 | doc/pprof-test-big.gif 17 | doc/pprof-test.gif 18 | doc/pprof-vsnprintf-big.gif 19 | doc/pprof-vsnprintf.gif 20 | doc/pprof.1 21 | doc/pprof_remote_servers.html 22 | doc/spanmap.gif 23 | doc/t-test1.times.txt 24 | doc/tcmalloc-opspercpusec.vs.threads.1024.bytes.png 25 | doc/tcmalloc-opspercpusec.vs.threads.128.bytes.png 26 | doc/tcmalloc-opspercpusec.vs.threads.131072.bytes.png 27 | doc/tcmalloc-opspercpusec.vs.threads.16384.bytes.png 28 | doc/tcmalloc-opspercpusec.vs.threads.2048.bytes.png 29 | doc/tcmalloc-opspercpusec.vs.threads.256.bytes.png 30 | doc/tcmalloc-opspercpusec.vs.threads.32768.bytes.png 31 | doc/tcmalloc-opspercpusec.vs.threads.4096.bytes.png 32 | doc/tcmalloc-opspercpusec.vs.threads.512.bytes.png 33 | doc/tcmalloc-opspercpusec.vs.threads.64.bytes.png 34 | doc/tcmalloc-opspercpusec.vs.threads.65536.bytes.png 35 | doc/tcmalloc-opspercpusec.vs.threads.8192.bytes.png 36 | doc/tcmalloc-opspersec.vs.size.1.threads.png 37 | doc/tcmalloc-opspersec.vs.size.12.threads.png 38 | doc/tcmalloc-opspersec.vs.size.16.threads.png 39 | doc/tcmalloc-opspersec.vs.size.2.threads.png 40 | doc/tcmalloc-opspersec.vs.size.20.threads.png 41 | doc/tcmalloc-opspersec.vs.size.3.threads.png 42 | doc/tcmalloc-opspersec.vs.size.4.threads.png 43 | doc/tcmalloc-opspersec.vs.size.5.threads.png 44 | doc/tcmalloc-opspersec.vs.size.8.threads.png 45 | doc/tcmalloc.html 46 | doc/threadheap.gif 47 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/packages/deb/libgoogle-perftools-dev.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | usr/include 3 | usr/include/google 4 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/packages/deb/libgoogle-perftools-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/google/* 2 | usr/lib/lib*.so 3 | usr/lib/lib*.a 4 | usr/lib/*.la 5 | debian/tmp/usr/include/google/* 6 | debian/tmp/usr/lib/lib*.so 7 | debian/tmp/usr/lib/lib*.a 8 | debian/tmp/usr/lib/*.la 9 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/packages/deb/libgoogle-perftools0.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | usr/bin 3 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/packages/deb/libgoogle-perftools0.install: -------------------------------------------------------------------------------- 1 | usr/lib/lib*.so.* 2 | usr/bin/pprof* 3 | debian/tmp/usr/lib/lib*.so.* 4 | debian/tmp/usr/bin/pprof* 5 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/packages/deb/libgoogle-perftools0.manpages: -------------------------------------------------------------------------------- 1 | doc/pprof.1 2 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/packages/rpm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | # Run this from the 'packages' directory, just under rootdir 4 | 5 | # We can only build rpm packages, if the rpm build tools are installed 6 | if [ \! -x /usr/bin/rpmbuild ] 7 | then 8 | echo "Cannot find /usr/bin/rpmbuild. Not building an rpm." 1>&2 9 | exit 0 10 | fi 11 | 12 | # Check the commandline flags 13 | PACKAGE="$1" 14 | VERSION="$2" 15 | fullname="${PACKAGE}-${VERSION}" 16 | archive=../$fullname.tar.gz 17 | 18 | if [ -z "$1" -o -z "$2" ] 19 | then 20 | echo "Usage: $0 " 1>&2 21 | exit 0 22 | fi 23 | 24 | # Double-check we're in the packages directory, just under rootdir 25 | if [ \! -r ../Makefile -a \! -r ../INSTALL ] 26 | then 27 | echo "Must run $0 in the 'packages' directory, under the root directory." 1>&2 28 | echo "Also, you must run \"make dist\" before running this script." 1>&2 29 | exit 0 30 | fi 31 | 32 | if [ \! -r "$archive" ] 33 | then 34 | echo "Cannot find $archive. Run \"make dist\" first." 1>&2 35 | exit 0 36 | fi 37 | 38 | # Create the directory where the input lives, and where the output should live 39 | RPM_SOURCE_DIR="/tmp/rpmsource-$fullname" 40 | RPM_BUILD_DIR="/tmp/rpmbuild-$fullname" 41 | 42 | trap 'rm -rf $RPM_SOURCE_DIR $RPM_BUILD_DIR; exit $?' EXIT SIGHUP SIGINT SIGTERM 43 | 44 | rm -rf "$RPM_SOURCE_DIR" "$RPM_BUILD_DIR" 45 | mkdir "$RPM_SOURCE_DIR" 46 | mkdir "$RPM_BUILD_DIR" 47 | 48 | cp "$archive" "$RPM_SOURCE_DIR" 49 | 50 | rpmbuild -bb rpm/rpm.spec \ 51 | --define "NAME $PACKAGE" \ 52 | --define "VERSION $VERSION" \ 53 | --define "_sourcedir $RPM_SOURCE_DIR" \ 54 | --define "_builddir $RPM_BUILD_DIR" \ 55 | --define "_rpmdir $RPM_SOURCE_DIR" 56 | 57 | # We put the output in a directory based on what system we've built for 58 | destdir=rpm-unknown 59 | if [ -r /etc/issue ] 60 | then 61 | grep "Red Hat.*release 7" /etc/issue >/dev/null 2>&1 && destdir=rh7 62 | grep "Red Hat.*release 8" /etc/issue >/dev/null 2>&1 && destdir=rh8 63 | grep "Red Hat.*release 9" /etc/issue >/dev/null 2>&1 && destdir=rh9 64 | grep "Fedora Core.*release 1" /etc/issue >/dev/null 2>&1 && destdir=fc1 65 | grep "Fedora Core.*release 2" /etc/issue >/dev/null 2>&1 && destdir=fc2 66 | grep "Fedora Core.*release 3" /etc/issue >/dev/null 2>&1 && destdir=fc3 67 | fi 68 | 69 | rm -rf "$destdir" 70 | mkdir -p "$destdir" 71 | # We want to get not only the main package but devel etc, hence the middle * 72 | mv "$RPM_SOURCE_DIR"/*/"${PACKAGE}"-*"${VERSION}"*.rpm "$destdir" 73 | 74 | echo 75 | echo "The rpm package file(s) are located in $PWD/$destdir" 76 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/src/base/googleinit.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // --- 31 | // Author: Jacob Hoffman-Andrews 32 | 33 | #ifndef _GOOGLEINIT_H 34 | #define _GOOGLEINIT_H 35 | 36 | class GoogleInitializer { 37 | public: 38 | typedef void (*void_function)(void); 39 | GoogleInitializer(const char* name, void_function f) { 40 | f(); 41 | } 42 | }; 43 | 44 | #define REGISTER_MODULE_INITIALIZER(name, body) \ 45 | namespace { \ 46 | static void google_init_module_##name () { body; } \ 47 | GoogleInitializer google_initializer_module_##name(#name, \ 48 | google_init_module_##name); \ 49 | } 50 | 51 | #endif /* _GOOGLEINIT_H */ 52 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/src/base/linuxthreads.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2005-2007, Google Inc. 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * * Neither the name of Google Inc. nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * --- 31 | * Author: Markus Gutschke 32 | */ 33 | 34 | #ifndef _LINUXTHREADS_H 35 | #define _LINUXTHREADS_H 36 | 37 | /* Include thread_lister.h to get the interface that we implement for linux. 38 | */ 39 | 40 | /* We currently only support x86-32 and x86-64 on Linux. Porting to other 41 | * related platforms should not be difficult. 42 | */ 43 | #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ 44 | defined(mips)) && defined(__linux) 45 | 46 | /* Define the THREADS symbol to make sure that there is exactly one core dumper 47 | * built into the library. 48 | */ 49 | #define THREADS "Linux /proc" 50 | 51 | #endif 52 | 53 | #endif /* _LINUXTHREADS_H */ 54 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/src/base/logging.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // --- 31 | // This file just provides storage for FLAGS_verbose. 32 | 33 | #include "base/commandlineflags.h" 34 | 35 | DEFINE_int32(verbose, EnvToInt("PERFTOOLS_VERBOSE", 0), 36 | "Set to numbers >0 for more verbose output, or <0 for less. " 37 | "--verbose == -4 means we log fatal errors only."); 38 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/src/google/perftools/hash_set.h: -------------------------------------------------------------------------------- 1 | #include 2 | #ifndef HASH_NAMESPACE 3 | #define HASH_NAMESPACE __gnu_cxx 4 | #endif 5 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/src/maybe_threads.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // --- 31 | // Author: Paul Menage 32 | 33 | //------------------------------------------------------------------- 34 | // Some wrappers for pthread functions so that we can be LD_PRELOADed 35 | // against non-pthreads apps. 36 | //------------------------------------------------------------------- 37 | 38 | #include 39 | 40 | int perftools_pthread_key_create(pthread_key_t *key, 41 | void (*destr_function) (void *)); 42 | void *perftools_pthread_getspecific(pthread_key_t key); 43 | int perftools_pthread_setspecific(pthread_key_t key, void *val); 44 | int perftools_pthread_once(pthread_once_t *ctl, 45 | void (*init_routine) (void)); 46 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/src/stamp-h1: -------------------------------------------------------------------------------- 1 | timestamp for src/config.h 2 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/src/tests/ptmalloc/lran2.h: -------------------------------------------------------------------------------- 1 | /* lran2.h 2 | * by Wolfram Gloger 1996. 3 | * 4 | * A small, portable pseudo-random number generator. 5 | */ 6 | 7 | #ifndef _LRAN2_H 8 | #define _LRAN2_H 9 | 10 | #define LRAN2_MAX 714025l /* constants for portable */ 11 | #define IA 1366l /* random number generator */ 12 | #define IC 150889l /* (see e.g. `Numerical Recipes') */ 13 | 14 | struct lran2_st { 15 | long x, y, v[97]; 16 | }; 17 | 18 | static void 19 | lran2_init(struct lran2_st* d, long seed) 20 | { 21 | long x; 22 | int j; 23 | 24 | x = (IC - seed) % LRAN2_MAX; 25 | if(x < 0) x = -x; 26 | for(j=0; j<97; j++) { 27 | x = (IA*x + IC) % LRAN2_MAX; 28 | d->v[j] = x; 29 | } 30 | d->x = (IA*x + IC) % LRAN2_MAX; 31 | d->y = d->x; 32 | } 33 | 34 | #ifdef __GNUC__ 35 | __inline__ 36 | #endif 37 | static long 38 | lran2(struct lran2_st* d) 39 | { 40 | int j = (d->y % 97); 41 | 42 | d->y = d->v[j]; 43 | d->x = (IA*d->x + IC) % LRAN2_MAX; 44 | d->v[j] = d->x; 45 | return d->y; 46 | } 47 | 48 | #undef IA 49 | #undef IC 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /allocators/tcmalloc/google-perftools-0.91/src/tests/testutil.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // --- 31 | // Author: Craig Silverstein 32 | 33 | #ifndef TCMALLOC_TOOLS_TESTUTIL_H__ 34 | #define TCMALLOC_TOOLS_TESTUTIL_H__ 35 | 36 | // Run a function in a thread of its own and wait for it to finish. 37 | // The function you pass in must have the signature 38 | // void MyFunction(); 39 | extern void RunInThread(void (*fn)()); 40 | 41 | #endif // TCMALLOC_TOOLS_TESTUTIL_H__ 42 | --------------------------------------------------------------------------------