Revert last patch to xmalloc.c, and instead bring over this patch from

egcs:
Thu Apr 15 23:00:55 1999  Mumit Khan  <khan@xraylith.wisc.edu>

	* configure.in (checkfuncs): Check for sbrk.
	* config.in: Rebuilt.
	* configure: Likewise.
	* xmalloc.c: Use HAVE_SBRK instead of the host specific definitions.
This commit is contained in:
Ian Lance Taylor
1999-08-05 21:15:29 +00:00
parent 5d54c62870
commit c1687039eb
5 changed files with 193 additions and 125 deletions

View File

@@ -1,5 +1,5 @@
/* memory allocation routines with error checking.
Copyright 1989, 90, 91, 92, 93, 94, 1999 Free Software Foundation, Inc.
Copyright 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
@@ -43,32 +43,22 @@ PTR sbrk PARAMS ((ptrdiff_t));
/* The program name if set. */
static const char *name = "";
#if !defined (__CYGWIN__) && defined (__CYGWIN32__)
#define __CYGWIN__ 1
#endif
/* On Unix systems we use sbrk to determine how much memory has been
allocated. */
#undef USE_SBRK
#if (! defined (_WIN32) && ! defined (__INTERIX)) || defined (__CYGWIN__) || defined (__UWIN__)
#define USE_SBRK
#endif
#ifdef USE_SBRK
#ifdef HAVE_SBRK
/* The initial sbrk, set when the program name is set. Not used for win32
ports other than cygwin32. */
static char *first_break = NULL;
#endif
#endif /* HAVE_SBRK */
void
xmalloc_set_program_name (s)
const char *s;
{
name = s;
#ifdef USE_SBRK
#ifdef HAVE_SBRK
/* Win32 ports other than cygwin32 don't have brk() */
if (first_break == NULL)
first_break = (char *) sbrk (0);
#endif
#endif /* HAVE_SBRK */
}
PTR
@@ -82,7 +72,7 @@ xmalloc (size)
newmem = malloc (size);
if (!newmem)
{
#ifdef USE_SBRK
#ifdef HAVE_SBRK
extern char **environ;
size_t allocated;
@@ -94,12 +84,12 @@ xmalloc (size)
"\n%s%sCan not allocate %lu bytes after allocating %lu bytes\n",
name, *name ? ": " : "",
(unsigned long) size, (unsigned long) allocated);
#else
#else /* HAVE_SBRK */
fprintf (stderr,
"\n%s%sCan not allocate %lu bytes\n",
name, *name ? ": " : "",
(unsigned long) size);
#endif /* ! USE_SBRK */
#endif /* HAVE_SBRK */
xexit (1);
}
return (newmem);
@@ -117,7 +107,7 @@ xcalloc (nelem, elsize)
newmem = calloc (nelem, elsize);
if (!newmem)
{
#ifdef USE_SBRK
#ifdef HAVE_SBRK
extern char **environ;
size_t allocated;
@@ -129,12 +119,12 @@ xcalloc (nelem, elsize)
"\n%s%sCan not allocate %lu bytes after allocating %lu bytes\n",
name, *name ? ": " : "",
(unsigned long) (nelem * elsize), (unsigned long) allocated);
#else
#else /* HAVE_SBRK */
fprintf (stderr,
"\n%s%sCan not allocate %lu bytes\n",
name, *name ? ": " : "",
(unsigned long) (nelem * elsize));
#endif /* ! USE_SBRK */
#endif /* HAVE_SBRK */
xexit (1);
}
return (newmem);
@@ -155,7 +145,7 @@ xrealloc (oldmem, size)
newmem = realloc (oldmem, size);
if (!newmem)
{
#ifdef USE_SBRK
#ifdef HAVE_SBRK
extern char **environ;
size_t allocated;
@@ -167,12 +157,12 @@ xrealloc (oldmem, size)
"\n%s%sCan not reallocate %lu bytes after allocating %lu bytes\n",
name, *name ? ": " : "",
(unsigned long) size, (unsigned long) allocated);
#else
#else /* HAVE_SBRK */
fprintf (stderr,
"\n%s%sCan not reallocate %lu bytes\n",
name, *name ? ": " : "",
(unsigned long) size);
#endif /* ! USE_SBRK */
#endif /* HAVE_SBRK */
xexit (1);
}
return (newmem);