"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/include/util/alignedmmap.h" between
Hoard-3.12.tar.gz and Hoard-3.13.tar.gz

About: The Hoard memory allocator is a drop-in replacement for malloc() that can improve application performance, especially for multithreaded programs running on multiprocessors (hint: newer releases now part of the HeapLayers package).

alignedmmap.h  (Hoard-3.12):alignedmmap.h  (Hoard-3.13)
// -*- C++ -*- // -*- C++ -*-
/* /*
The Hoard Multiprocessor Memory Allocator The Hoard Multiprocessor Memory Allocator
www.hoard.org www.hoard.org
Author: Emery Berger, http://www.emeryberger.org Author: Emery Berger, http://www.emeryberger.org
Copyright (c) 1998-2015 Emery Berger Copyright (c) 1998-2018 Emery Berger
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/** /**
* @file alignedmmap.h * @file alignedmmap.h
* @author Emery Berger <http://www.cs.umass.edu/~emery> * @author Emery Berger <http://www.emeryberger.com>
*/ */
#ifndef HOARD_ALIGNEDMMAP_H #ifndef HOARD_ALIGNEDMMAP_H
#define HOARD_ALIGNEDMMAP_H #define HOARD_ALIGNEDMMAP_H
#include "heaplayers.h" #include "heaplayers.h"
#include "mmapalloc.h" #include "mmapalloc.h"
using namespace std; using namespace std;
using namespace HL; using namespace HL;
skipping to change at line 81 skipping to change at line 81
sz = HL::align<HL::MmapWrapper::Size>(sz); sz = HL::align<HL::MmapWrapper::Size>(sz);
// If the memory is already suitably aligned, just track size requests. // If the memory is already suitably aligned, just track size requests.
if ((size_t) HL::MmapWrapper::Alignment % (size_t) Alignment == 0) { if ((size_t) HL::MmapWrapper::Alignment % (size_t) Alignment == 0) {
void * ptr = HL::MmapWrapper::map (sz); void * ptr = HL::MmapWrapper::map (sz);
MyMap.set (ptr, sz); MyMap.set (ptr, sz);
assert ((size_t) ptr % Alignment == 0); assert ((size_t) ptr % Alignment == 0);
return ptr; return ptr;
} }
void * ptr = NULL; void * ptr = nullptr;
// Try a map call and hope that it's suitably aligned. If we get lucky, // Try a map call and hope that it's suitably aligned. If we get lucky,
// we're done. // we're done.
ptr = HL::MmapWrapper::map (sz); ptr = HL::MmapWrapper::map (sz);
if ((size_t) ptr == HL::align<Alignment>((size_t) ptr)) { if ((size_t) ptr == HL::align<Alignment>((size_t) ptr)) {
// We're done. // We're done.
MyMap.set (ptr, sz); MyMap.set (ptr, sz);
return ptr; return ptr;
skipping to change at line 131 skipping to change at line 131
private: private:
void * slowMap (size_t sz) { void * slowMap (size_t sz) {
// We have to align it ourselves. We get memory from // We have to align it ourselves. We get memory from
// mmap, align a pointer in the space, and free the space before // mmap, align a pointer in the space, and free the space before
// and after the aligned segment. // and after the aligned segment.
void * ptr = reinterpret_cast<char *>(HL::MmapWrapper::map (sz + Alignment )); void * ptr = reinterpret_cast<char *>(HL::MmapWrapper::map (sz + Alignment ));
if (ptr == NULL) { if (ptr == nullptr) {
return NULL; return nullptr;
} }
char * newptr = (char *) HL::align<Alignment>((size_t) ptr); char * newptr = (char *) HL::align<Alignment>((size_t) ptr);
// Unmap the part before (prolog) and after. // Unmap the part before (prolog) and after.
size_t prolog = (size_t) newptr - (size_t) ptr; size_t prolog = (size_t) newptr - (size_t) ptr;
if (prolog > 0) { if (prolog > 0) {
// Get rid of the prolog. // Get rid of the prolog.
 End of changes. 4 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)