Commit c4c10bb0 authored by Per Cederqvist's avatar Per Cederqvist

GNU malloc is no longer distributed with the LysKOM server.

parent fad6cbd2
This diff is collapsed.
1998-07-09 Per Cederqvist <ceder@lysator.liu.se>
* Makefile.in: No longer kept under version control.
1998-07-08 Per Cederqvist <ceder@lysator.liu.se>
* Makefile.am: New file. The lyskomd build environment now uses
automake.
Thu Nov 2 20:43:12 1995 Per Cederqvist (ceder@lysator.liu.se)
* gmalloc.c: File removed, since it is so easilly generated.
* Makefile.src: Template file added.
* Makefile: File removed. A Makefile is generated from
Makefile.src by the lyskomd build environment.
This file documents changes made to the GNU Malloc Library by
the LysKOM development team.
Find older changes in OChangeLog.
# $Id: Makefile.am,v 1.1 1998/07/08 12:47:35 ceder Exp $
# Copyright (C) 1998 Lysator Academic Computer Association.
#
# This file is part of the LysKOM server.
#
# LysKOM is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 1, or (at your option)
# any later version.
#
# LysKOM 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 General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with LysKOM; see the file COPYING. If not, write to
# Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
# or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
# MA 02139, USA.
#
# Please mail bug reports to bug-lyskom@lysator.liu.se.
#
noinst_LIBRARIES = libgmalloc.a
libgmalloc_a_SOURCES = mcheck.c mtrace.c mstats.c
vm-limit.c ralloc.c malloc-find.c malloc.h
libgmalloc_a_LIBADD = gmalloc.o
gmalloc=gmalloc-head.c malloc.h valloc.c malloc.c free.c cfree.c \
realloc.c calloc.c morecore.c memalign.c
gmalloc.c: $(gmalloc)
$(RM) $@.tmp $@
cat $+ > $@.tmp
chmod a-w $@.tmp
mv -f $@.tmp $@
**** All newer entries are in the C library ChangeLog file. ****
Thu Jul 11 18:15:04 1991 Roland McGrath (roland@churchy.gnu.ai.mit.edu)
* Merged with C library version, which now has its own subdir.
* malloc.h, *.c: Use ansideclisms and #ifdefs for portability both
in and out of the C library.
* Makefile: New makefile for malloc subdir in libc.
Has targets to create malloc.tar{,.Z} by ansidecl processing on srcs.
* malloc/Makefile: New file; Makefile for standalone distribution.
* malloc/README: New file; info for same.
Fri Apr 6 00:18:36 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
* Makefile: Add comments.
Thu Apr 5 23:08:14 1990 Mike Haertel (mike at albert.ai.mit.edu)
* mcheck.c (mcheck, checkhdr): Support user-supplied abort()
function.
* malloc.h: Declare __free().
* Makefile: New target libmalloc.a.
Thu Apr 5 21:56:03 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
* free.c (free): Split into free and __free.
* malloc.c (morecore): Call __free on oldinfo.
Local Variables:
mode: indented-text
left-margin: 8
fill-column: 76
version-control: never
End:
This is the standalone distribution of GNU malloc.
GNU malloc is part of the GNU C Library, but is also distributed separately.
If you find bugs in GNU malloc, send reports to bug-glibc@prep.ai.mit.edu.
GNU malloc is free software. See the file COPYING.LIB for copying conditions.
The makefile builds libmalloc.a and gmalloc.o. If you are using GNU malloc
to replace your system's existing malloc package, it is important to make
sure you get all GNU functions, not some of the GNU functions and some from
the system library. gmalloc.o has all the functions in one file, so using
that will make sure you don't accidentally mix the two malloc packages.
/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA.
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
#ifndef _MALLOC_INTERNAL
#define _MALLOC_INTERNAL
#include <malloc.h>
#endif
/* Allocate an array of NMEMB elements each SIZE bytes long.
The entire array is initialized to zeros. */
__ptr_t
calloc (nmemb, size)
register __malloc_size_t nmemb;
register __malloc_size_t size;
{
register __ptr_t result = malloc (nmemb * size);
if (result != NULL)
(void) memset (result, 0, nmemb * size);
return result;
}
/* Copyright (C) 1991, 1993, 1994 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 Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#ifndef _MALLOC_INTERNAL
#define _MALLOC_INTERNAL
#include <malloc.h>
#endif
#ifdef _LIBC
#include <ansidecl.h>
#include <gnu-stabs.h>
#undef cfree
function_alias(cfree, free, void, (ptr),
DEFUN(cfree, (ptr), PTR ptr))
#else
void
cfree (ptr)
__ptr_t ptr;
{
free (ptr);
}
#endif
/* Free a block of memory allocated by `malloc'.
Copyright 1990, 1991, 1992, 1994 Free Software Foundation, Inc.
Written May 1989 by Mike Haertel.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA.
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
#ifndef _MALLOC_INTERNAL
#define _MALLOC_INTERNAL
#include <malloc.h>
#endif
/* Debugging hook for free. */
void (*__free_hook) __P ((__ptr_t __ptr));
/* List of blocks allocated by memalign. */
struct alignlist *_aligned_blocks = NULL;
/* Return memory to the heap.
Like `free' but don't call a __free_hook if there is one. */
void
_free_internal (ptr)
__ptr_t ptr;
{
int type;
__malloc_size_t block, blocks;
register __malloc_size_t i;
struct list *prev, *next;
block = BLOCK (ptr);
type = _heapinfo[block].busy.type;
switch (type)
{
case 0:
/* Get as many statistics as early as we can. */
--_chunks_used;
_bytes_used -= _heapinfo[block].busy.info.size * BLOCKSIZE;
_bytes_free += _heapinfo[block].busy.info.size * BLOCKSIZE;
/* Find the free cluster previous to this one in the free list.
Start searching at the last block referenced; this may benefit
programs with locality of allocation. */
i = _heapindex;
if (i > block)
while (i > block)
i = _heapinfo[i].free.prev;
else
{
do
i = _heapinfo[i].free.next;
while (i > 0 && i < block);
i = _heapinfo[i].free.prev;
}
/* Determine how to link this block into the free list. */
if (block == i + _heapinfo[i].free.size)
{
/* Coalesce this block with its predecessor. */
_heapinfo[i].free.size += _heapinfo[block].busy.info.size;
block = i;
}
else
{
/* Really link this block back into the free list. */
_heapinfo[block].free.size = _heapinfo[block].busy.info.size;
_heapinfo[block].free.next = _heapinfo[i].free.next;
_heapinfo[block].free.prev = i;
_heapinfo[i].free.next = block;
_heapinfo[_heapinfo[block].free.next].free.prev = block;
++_chunks_free;
}
/* Now that the block is linked in, see if we can coalesce it
with its successor (by deleting its successor from the list
and adding in its size). */
if (block + _heapinfo[block].free.size == _heapinfo[block].free.next)
{
_heapinfo[block].free.size
+= _heapinfo[_heapinfo[block].free.next].free.size;
_heapinfo[block].free.next
= _heapinfo[_heapinfo[block].free.next].free.next;
_heapinfo[_heapinfo[block].free.next].free.prev = block;
--_chunks_free;
}
/* Now see if we can return stuff to the system. */
blocks = _heapinfo[block].free.size;
if (blocks >= FINAL_FREE_BLOCKS && block + blocks == _heaplimit
&& (*__morecore) (0) == ADDRESS (block + blocks))
{
register __malloc_size_t bytes = blocks * BLOCKSIZE;
_heaplimit -= blocks;
(*__morecore) (-bytes);
_heapinfo[_heapinfo[block].free.prev].free.next
= _heapinfo[block].free.next;
_heapinfo[_heapinfo[block].free.next].free.prev
= _heapinfo[block].free.prev;
block = _heapinfo[block].free.prev;
--_chunks_free;
_bytes_free -= bytes;
}
/* Set the next search to begin at this block. */
_heapindex = block;
break;
default:
/* Do some of the statistics. */
--_chunks_used;
_bytes_used -= 1 << type;
++_chunks_free;
_bytes_free += 1 << type;
/* Get the address of the first free fragment in this block. */
prev = (struct list *) ((char *) ADDRESS (block) +
(_heapinfo[block].busy.info.frag.first << type));
if (_heapinfo[block].busy.info.frag.nfree == (BLOCKSIZE >> type) - 1)
{
/* If all fragments of this block are free, remove them
from the fragment list and free the whole block. */
next = prev;
for (i = 1; i < (__malloc_size_t) (BLOCKSIZE >> type); ++i)
next = next->next;
prev->prev->next = next;
if (next != NULL)
next->prev = prev->prev;
_heapinfo[block].busy.type = 0;
_heapinfo[block].busy.info.size = 1;
/* Keep the statistics accurate. */
++_chunks_used;
_bytes_used += BLOCKSIZE;
_chunks_free -= BLOCKSIZE >> type;
_bytes_free -= BLOCKSIZE;
free (ADDRESS (block));
}
else if (_heapinfo[block].busy.info.frag.nfree != 0)
{
/* If some fragments of this block are free, link this
fragment into the fragment list after the first free
fragment of this block. */
next = (struct list *) ptr;
next->next = prev->next;
next->prev = prev;
prev->next = next;
if (next->next != NULL)
next->next->prev = next;
++_heapinfo[block].busy.info.frag.nfree;
}
else
{
/* No fragments of this block are free, so link this
fragment into the fragment list and announce that
it is the first free fragment of this block. */
prev = (struct list *) ptr;
_heapinfo[block].busy.info.frag.nfree = 1;
_heapinfo[block].busy.info.frag.first = (unsigned long int)
((unsigned long int) ((char *) ptr - (char *) NULL)
% BLOCKSIZE >> type);
prev->next = _fraghead[type].next;
prev->prev = &_fraghead[type];
prev->prev->next = prev;
if (prev->next != NULL)
prev->next->prev = prev;
}
break;
}
}
/* Return memory to the heap. */
void
free (ptr)
__ptr_t ptr;
{
register struct alignlist *l;
if (ptr == NULL)
return;
for (l = _aligned_blocks; l != NULL; l = l->next)
if (l->aligned == ptr)
{
l->aligned = NULL; /* Mark the slot in the list as free. */
ptr = l->exact;
break;
}
if (__free_hook != NULL)
(*__free_hook) (ptr);
else
_free_internal (ptr);
}
/* Emulate getpagesize on systems that lack it. */
#ifndef HAVE_GETPAGESIZE
#ifdef VMS
#define getpagesize() 512
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef _SC_PAGESIZE
#define getpagesize() sysconf(_SC_PAGESIZE)
#else
#include <sys/param.h>
#ifdef EXEC_PAGESIZE
#define getpagesize() EXEC_PAGESIZE
#else
#ifdef NBPG
#define getpagesize() NBPG * CLSIZE
#ifndef CLSIZE
#define CLSIZE 1
#endif /* no CLSIZE */
#else /* no NBPG */
#ifdef NBPC
#define getpagesize() NBPC
#else /* no NBPC */
#ifdef PAGESIZE
#define getpagesize() PAGESIZE
#endif
#endif /* NBPC */
#endif /* no NBPG */
#endif /* no EXEC_PAGESIZE */
#endif /* no _SC_PAGESIZE */
#endif /* not HAVE_GETPAGESIZE */
/* DO NOT EDIT THIS FILE -- it is automagically generated. -*- C -*- */
#define _MALLOC_INTERNAL
/* The malloc headers and source files from the C library follow here. */
/* Find the starting address of a malloc'd block, from anywhere inside it.
Copyright (C) 1995 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
the C library, however. The master source lives in /gd/gnu/lib.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#ifndef _MALLOC_INTERNAL
#define _MALLOC_INTERNAL
#include <malloc.h>
#endif
/* Given an address in the middle of a malloc'd object,
return the address of the beginning of the object. */
__ptr_t
malloc_find_object_address (ptr)
__ptr_t ptr;
{
__malloc_size_t block = BLOCK (ptr);
int type = _heapinfo[block].busy.type;
if (type == 0)
{
/* The object is one or more entire blocks. */
__malloc_ptrdiff_t sizevalue = _heapinfo[block].busy.info.size;
if (sizevalue < 0)
/* This is one of the blocks after the first. SIZEVALUE
says how many blocks to go back to find the first. */
block += sizevalue;
/* BLOCK is now the first block of the object.
Its start is the start of the object. */
return ADDRESS (block);
}
else
{
/* Get the size of fragments in this block. */
__malloc_size_t size = 1 << type;
/* Turn off the low bits to find the start address of the fragment. */
return _heapbase + (((char *) ptr - _heapbase) & ~(size - 1));
}
}
/* Memory allocator `malloc'.
Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
Written May 1989 by Mike Haertel.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA.
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
#ifndef _MALLOC_INTERNAL
#define _MALLOC_INTERNAL
#include <malloc.h>
#endif
/* How to really get more memory. */
__ptr_t (*__morecore) __P ((ptrdiff_t __size)) = __default_morecore;
/* Debugging hook for `malloc'. */
__ptr_t (*__malloc_hook) __P ((__malloc_size_t __size));
/* Pointer to the base of the first block. */
char *_heapbase;
/* Block information table. Allocated with align/__free (not malloc/free). */
malloc_info *_heapinfo;
/* Number of info entries. */
static __malloc_size_t heapsize;
/* Search index in the info table. */
__malloc_size_t _heapindex;
/* Limit of valid info table indices. */
__malloc_size_t _heaplimit;
/* Free lists for each fragment size. */
struct list _fraghead[BLOCKLOG];
/* Instrumentation. */
__malloc_size_t _chunks_used;
__malloc_size_t _bytes_used;
__malloc_size_t _chunks_free;
__malloc_size_t _bytes_free;
/* Are you experienced? */
int __malloc_initialized;
void (*__malloc_initialize_hook) __P ((void));
void (*__after_morecore_hook) __P ((void));
/* Aligned allocation. */
static __ptr_t align __P ((__malloc_size_t));
static __ptr_t
align (size)
__malloc_size_t size;
{
__ptr_t result;
unsigned long int adj;
result = (*__morecore) (size);
adj = (unsigned long int) ((unsigned long int) ((char *) result -
(char *) NULL)) % BLOCKSIZE;
if (adj != 0)
{
adj = BLOCKSIZE - adj;
(void) (*__morecore) (adj);
result = (char *) result + adj;
}
if (__after_morecore_hook)
(*__after_morecore_hook) ();
return result;
}
/* Set everything up and remember that we have. */
static int initialize __P ((void));
static int
initialize ()
{
if (__malloc_initialize_hook)
(*__malloc_initialize_hook) ();
heapsize = HEAP / BLOCKSIZE;
_heapinfo = (malloc_info *) align (heapsize * sizeof (malloc_info));
if (_heapinfo == NULL)
return 0;
memset (_heapinfo, 0, heapsize * sizeof (malloc_info));
_heapinfo[0].free.size = 0;
_heapinfo[0].free.next = _heapinfo[0].free.prev = 0;
_heapindex = 0;
_heapbase = (char *) _heapinfo;
/* Account for the _heapinfo block itself in the statistics. */
_bytes_used = heapsize * sizeof (malloc_info);
_chunks_used = 1;
__malloc_initialized = 1;
return 1;
}
/* Get neatly aligned memory, initializing or
growing the heap info table as necessary. */
static __ptr_t morecore __P ((__malloc_size_t));
static __ptr_t
morecore (size)
__malloc_size_t size;
{
__ptr_t result;
malloc_info *newinfo, *oldinfo;
__malloc_size_t newsize;
result = align (size);
if (result == NULL)
return NULL;