/* * libc/stdlib/malloc/heap_free.c -- return memory to a heap * * Copyright (C) 2002 NEC Corporation * Copyright (C) 2002 Miles Bader * * This file is subject to the terms and conditions of the GNU Lesser * General Public License. See the file COPYING.LIB in the main * directory of this archive for more details. * * Written by Miles Bader */ #include #include "heap.h" /* Return the block of memory at MEM, of size SIZE, to HEAP. */ struct heap_free_area * __heap_free (struct heap *heap, void *mem, size_t size) { struct heap_free_area *fa, *prev_fa; void *end = (char *)mem + size; HEAP_DEBUG (heap, "before __heap_free"); /* Find the right position in the free-list entry to place the new block. This is the most speed critical loop in this malloc implementation: since we use a simple linked-list for the free-list, and we keep it in address-sorted order, it can become very expensive to insert something in the free-list when it becomes fragmented and long. [A better implemention would use a balanced tree or something for the free-list, though that bloats the code-size and complexity quite a bit.] */ for (prev_fa = 0, fa = heap->free_areas; fa; prev_fa = fa, fa = fa->next) if (unlikely (HEAP_FREE_AREA_END (fa) >= mem)) break; if (fa && HEAP_FREE_AREA_START (fa) <= end) /* The free-area FA is adjacent to the new block, merge them. */ { size_t fa_size = fa->size + size; if (HEAP_FREE_AREA_START (fa) == end) /* FA is just after the new block, grow down to encompass it. */ { /* See if FA can now be merged with its predecessor. */ if (prev_fa && mem == HEAP_FREE_AREA_END (prev_fa)) /* Yup; merge PREV_FA's info into FA. */ { fa_size += prev_fa->size; __heap_link_free_area_after (heap, fa, prev_fa->prev); } } else /* FA is just before the new block, expand to encompass it. */ { struct heap_free_area *next_fa = fa->next; /* See if FA can now be merged with its successor. */ if (next_fa && end == HEAP_FREE_AREA_START (next_fa)) /* Yup; merge FA's info into NEXT_FA. */ { fa_size += next_fa->size; __heap_link_free_area_after (heap, next_fa, prev_fa); fa = next_fa; } else /* FA can't be merged; move the descriptor for it to the tail-end of the memory block. */ { /* The new descriptor is at the end of the extended block, SIZE bytes later than the old descriptor. */ fa = (struct heap_free_area *)((char *)fa + size); /* Update links with the neighbors in the list. */ __heap_link_free_area (heap, fa, prev_fa, next_fa); } } fa->size = fa_size; } else /* Make the new block into a separate free-list entry. */ fa = __heap_add_free_area (heap, mem, size, prev_fa, fa); HEAP_DEBUG (heap, "after __heap_free"); return fa; } de4062e6b8c48f3c9b5148d'/>
context:
space:
mode:
Diffstat (limited to 'libpthread/linuxthreads/ptclock_settime.c')
-rw-r--r--libpthread/linuxthreads/ptclock_settime.c55
1 files changed, 0 insertions, 55 deletions
diff --git a/libpthread/linuxthreads/ptclock_settime.c b/libpthread/linuxthreads/ptclock_settime.c
deleted file mode 100644
index a4f218c77..000000000
--- a/libpthread/linuxthreads/ptclock_settime.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright (C) 2001, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#include <errno.h>
-#include <time.h>
-#include <libc-internal.h>
-#include "internals.h"
-#include "spinlock.h"
-
-
-#if HP_TIMING_AVAIL
-int
-__pthread_clock_settime (clockid_t clock_id, hp_timing_t offset)
-{
- pthread_descr self = thread_self ();
- pthread_t thread = ((unsigned int) clock_id) >> CLOCK_IDFIELD_SIZE;
- const unsigned int mask = ~0U >> CLOCK_IDFIELD_SIZE;
-
- if (thread == 0 || (THREAD_GETMEM (self, p_tid) & mask) == thread)
- /* Our own clock. */
- THREAD_SETMEM (self, p_cpuclock_offset, offset);
- else
- {
- pthread_descr th;
- pthread_handle handle = thread_handle (thread);
- __pthread_lock (&handle->h_lock, NULL);
- th = handle->h_descr;
- if (th == NULL || (th->p_tid & mask) != thread || th->p_terminated)
- {
- __pthread_unlock (&handle->h_lock);
- __set_errno (EINVAL);
- return -1;
- }
- th->p_cpuclock_offset = offset;
- __pthread_unlock (&handle->h_lock);
- }
-
- return 0;
-}
-#endif