Ioannis Koutras пре 13 година
родитељ
комит
2551b00d3e
2 измењених фајлова са 0 додато и 177 уклоњено
  1. 0 9
      DefineOptions.cmake
  2. 0 168
      src/custom_realloc.c

+ 0 - 9
DefineOptions.cmake

@@ -4,7 +4,6 @@ option(HAVE_LOCKS "Build with POSIX locking mechanisms" ON)
 option(WITH_REALLOC "Build with realloc" OFF)
 set(TRACE_LEVEL 1 CACHE INTEGER "Choose the trace level, options are: 0, 1, 2 and 3")
 option(WITH_EXAMPLES "Build with examples" OFF)
-option(WITH_FIXED_LISTS "Build with predefined lists of fixed-sized blocks" ON)
 set(STATS "global" CACHE STRING "Choose if the memory allocator keeps internally statistics per raw block or globally, options are: none, rawblock, global")
 option(WITH_ADAPTIVITY "Build with adaptivity" OFF)
 option(WITH_STATIC_LIB "Build a static library" OFF)
@@ -40,7 +39,6 @@ if (P2012)
   set(WITH_STATIC_LIB ON)
   set(NUM_POOLS 1)
   set(LINUXTEST OFF)
-  set(WITH_FIXED_LISTS OFF)
   set(WITH_COALESCING "never")
   set(WITH_SPLITTING "never")
   set(BLOCKS_ORGANIZATION "sll")
@@ -52,7 +50,6 @@ if (LEON3)
   set(WITH_STATIC_LIB ON)
   set(NUM_POOLS 1)
   set(LINUXTEST OFF)
-  set(WITH_FIXED_LISTS OFF)
   set(COUNT_HOPS ON)
   set(WITH_COALESCING "never")
   set(WITH_SPLITTING "never")
@@ -62,7 +59,6 @@ endif (LEON3)
 if (LINUXTEST)
   set(WITH_SYSTEM_CALLS "mmap")
   set(SYS_ALLOC_SIZE 4194304)
-  set(WITH_FIXED_LISTS OFF)
   set(SORT_POLICY "lifo")
   set(SEARCH_POLICY "first")
   set(FIT_PERCENTAGE 0.6f)
@@ -162,8 +158,3 @@ elseif(WITH_SPLITTING STREQUAL "variable")
   set(WITH_KNOBS ON)
   set(SPLITTING_VARIABLE ON)
 endif(WITH_SPLITTING STREQUAL "fixed")
-
-if(COUNT_ACCESSES OR COUNT_HOPS)
- set(WITH_STATS ON)
-endif(COUNT_ACCESSES OR COUNT_HOPS)
-

+ 0 - 168
src/custom_realloc.c

@@ -1,168 +0,0 @@
-/*
- *   Copyright 2011 Institute of Communication and Computer Systems (ICCS) 
- *
- *   Licensed under the Apache License, Version 2.0 (the "License");
- *   you may not use this file except in compliance with the License.
- *   You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
- *
- */
-
-/**
- * \file    custom_realloc.c
- * \author  Ioannis Koutras (joko@microlab.ntua.gr)
- * \date    January, 2012
- *
- * \brief   Implementation of a function to change the size of an allocated
- * block.
- */
-
-#include <dmmlib/custom_realloc.h>
-#include <dmmlib/initialize_allocator.h>
-#include "block_header.h"
-#ifndef NO_SYSTEM_CALLS
-#include "other.h"
-#endif /* NO_SYSTEM_CALLS */
-#if defined (SPLITTING_FIXED) || defined (SPLITTING_VARIABLE)
-#include "split.h"
-#endif /* SPLITTING_FIXED || SPLITTING_VARIABLE */
-
-/**
- * Allocates a new block and copies the contents of the old block to the new
- * block. No check is done if there is an old block!
- */
-void * clean_realloc(allocator_t *allocator, heap_t *heap, void *ptr,
-        size_t size);
-/**
- * Copy a memory area
- */
-static void custom_memcpy(void* dest, const void* src, size_t n) {
-    char *dst8, *src8;
-    
-    dst8 = (char *) dest + HEADER_SIZE;
-    src8 = (char *) src + HEADER_SIZE;
-    
-    while(n--) {
-        *dst8++ = *src8++;
-    }
-}
-
-void * clean_realloc(allocator_t *allocator, heap_t *heap, void *ptr, 
-        size_t size) {
-    size_t old_size;
-    void *new_ptr;
-
-    old_size = get_size(ptr);
-    new_ptr = custom_ahmalloc(allocator, heap, size);
-    custom_memcpy(new_ptr, ptr, old_size);
-    custom_ahfree(allocator, heap, ptr);
-
-    return new_ptr;
-}
-
-/**
- * \details The realloc() function tries to change the size of the allocation
- * pointed to by ptr to size, and returns ptr. realloc() creates a new
- * allocation, copies as much of the old data pointed to by ptr as will fit to
- * the new allocation, frees the old allocation and returns a pointer to the
- * allocated memory. If ptr is NULL, realloc() is identical to a call to
- * malloc() for size bytes.
- */
-void * custom_ahrealloc(allocator_t *allocator, heap_t *heap, void *ptr, size_t size) {
-    void *next_block;
-    size_t old_size;
-#if defined (REQUEST_SIZE_INFO) && defined (WITH_STATS)
-    size_t old_requested_size;
-#endif /* (REQUEST_SIZE_INFO) && (WITH_STATS) */
-
-#if defined (SPLITTING_FIXED) || defined (SPLITTING_VARIABLE)
-    size_t min_split_size;
-#endif /* (SPLITTING_FIXED) || (SPLITTING_VARIABLE) */
-
-    if(ptr != NULL) {
-        old_size = get_size(ptr);
-        if(old_size > size) {
-            /* The old size is bigger than the new, use the old block */
-
-#ifdef REQUEST_SIZE_INFO
-#ifdef WITH_STATS
-            old_requested_size = get_requested_size(ptr);
-            heap->dmm_stats.mem_requested += old_requested_size;
-            heap->dmm_stats.mem_requested += size;
-#endif /* WITH_STATS */
-            set_requested_size(ptr, size);
-#endif /* REQUEST_SIZE_INFO */
-
-            /* Try to split the currently allocated block */
-#if defined (SPLITTING_FIXED) || defined (SPLITTING_VARIABLE)
-#ifdef SPLITTING_FIXED
-            min_split_size = MIN_SPLITTING_SIZE;
-#endif /* SPLITTING_FIXED */
-#ifdef SPLITTING_VARIABLE
-            min_split_size = heap->dmm_knobs.min_split_size;
-#endif /* SPLITTING_VARIABLE */
-
-            if(old_size - size - HEADER_SIZE >= min_split_size) {
-                split(allocator, heap, ptr, size);
-            }
-#endif /* (SPLITTING_FIXED) || (SPLITTING_VARIABLE) */
-            return ptr;
-        } else {
-            /* The new size can't fit in the old box */
-
-            /* Check if the block next to the original as in the data layout
-             * can be used.
-             */
-            next_block = get_dlnext(allocator, ptr);
-            if(next_block != NULL) {
-#ifndef WITH_OWNERSHIP
-                if(is_free(next_block) == true) {
-#else /* WITH_OWNERSHIP */
-                if(is_free(next_block) == true
-                        && get_owner(next_block) == get_owner(ptr)) {
-#endif /* WITH_OWNERSHIP */
-                    if(size < old_size + get_size(next_block) + HEADER_SIZE) {
-                        remove_block_from_lists(&next_block, heap);
-                        if(allocator->border_ptr == next_block) {
-                            allocator->border_ptr = ptr;
-                        }
-                        set_size_and_used(allocator,
-                                ptr,
-                                old_size + get_size(next_block) + HEADER_SIZE);
-
-#if defined (SPLITTING_FIXED) || defined (SPLITTING_VARIABLE)
-#ifdef SPLITTING_FIXED
-                        min_split_size = MIN_SPLITTING_SIZE;
-#endif /* SPLITTING_FIXED */
-#ifdef SPLITTING_VARIABLE
-                        min_split_size = heap->dmm_knobs.min_split_size;
-#endif /* SPLITTING_VARIABLE */
-
-                        if(get_size(ptr) - size >= min_split_size) {
-                            split(allocator, heap, ptr, size);
-                        }
-#endif /* (SPLITTING_FIXED) || (SPLITTING_VARIABLE) */
-
-                        return ptr;
-                    } else {
-                        return clean_realloc(allocator, heap, ptr, size);
-                    }
-                } else {
-                    return clean_realloc(allocator, heap, ptr, size);
-                }
-            } else {
-                return clean_realloc(allocator, heap, ptr, size);
-            }
-        }
-    } else {
-        /* ptr is NULL, call malloc() */
-        return custom_ahmalloc(allocator, heap, size);
-    }
-}