glibc/sysdeps/generic/sbrk.c
Ulrich Drepper b236e99d90 Upadte.
Tue Aug 27 17:45:21 1996  Ulrich Drepper  <drepper@cygnus.com>

	* Makerules: Add some test for correct version of GNU Make.

	* io/fcntl.h: Undo change from Mon Aug 26 22:22:17 1996.
	* sysdeps/unix/sysv/linux/fcntlbits.h: Place macros here instead.

	* sysdeps/generic/dl-sysdep.c: Initialize break address to
	avoid overwriting last page (OK, Roland).

Tue Aug 27 16:20:37 1996  Ulrich Drepper  <drepper@cygnus.com>

	* resolv/resolv.h: Update from BIND-4.9.5-T3A.
	* resolv/arpa/nameser.h: Likewise.
	* resolv/res_init.c: Likewise.
	* resolv/res_debug.c: Likewise.
	* resolv/res_mkquery.c: Likewise.

Tue Aug 27 15:47:04 1996  Ulrich Drepper  <drepper@cygnus.com>

	* elf/dl-error.c (catch): Define errstring element not as const.
	(_dl_catch_error): ERRSTRING argument is not const pointer.
	Initialize *ERRSTRING and *OBJNAME separately.
	* elf/link.h: Change prototype for `_dl_catch_error'.

	* elf/dl-load.c (_dl_map_object): Use separate variable for
	copied NAME to avoid `const' warning.

	* elf/dlerror.c: Make `last_errstring' variable not const pointer.

	* elf/rtld.c: Implement reading of /etc/ld.so.preload.  This
	provides preloading even for SUID binaries.
	Add some more casts to avoid signed<->unsigned warnings.

Tue Aug 27 15:40:28 1996  NIIBE Yutaka  <gniibe@mri.co.jp>

	* posix/sys/types.h: Define loff_t.
	* sysdeps/unix/sysv/linux/gnu/types.h: Define __loff_t.

Mon Aug 26 16:31:33 1996  Thomas Bushnell, n/BSG  <thomas@gnu.ai.mit.edu>

	* sysdeps/mach/hurd/setitimer.c (setitimer_locked): Tolerate NEW
	being null; in that case don't touch the timer at all (but do
	return something in OLD if necessary).

Mon Aug 26 13:35:16 1996  Thomas Bushnell, n/BSG  <thomas@gnu.ai.mit.edu>

	* sysdeps/mach/hurd/i386/init-first.c (__libc_multiple_libcs): New
 	variable.
	* sysdeps/i386/init-first.c: Likewise.
	* sysdeps/stub/init-first.c: Likewise.
1996-08-28 00:26:07 +00:00

69 lines
2.1 KiB
C

/* Copyright (C) 1991, 1995, 1996 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 General Public License as published by
the Free Software Foundation; either version 2, 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with the GNU C Library; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <unistd.h>
#include <errno.h>
/* Defined in brk.c. */
extern void *__curbrk;
extern int __brk (void *addr);
extern int __libc_multiple_libcs; /* Defined in init-first.c. */
/* Extend the process's data space by INCREMENT.
If INCREMENT is negative, shrink data space by - INCREMENT.
Return start of new space allocated, or -1 for errors. */
void *
__sbrk (ptrdiff_t increment)
{
void *oldbrk;
/* If this is not part of the dynamic library or the library is used
via dynamic loading in a statically linked program update
__curbrk from the kernel's brk value. That way two separate
instances of __brk and __sbrk can share the heap, returning
interleaved pieces of it. */
if (__curbrk == NULL || __libc_multiple_libcs)
{
extern void _end;
if (__brk (0) < 0) /* Initialize the break. */
return (void *) -1;
/* Align break address to page boundary if not happened before. */
if (!__libc_multiple_libcs && __curbrk == &_end)
{
size_t pg = __getpagesize ();
ptrdiff_t rest = pg - ((&_end - (void *) 0) & (pg - 1));
if (__brk (__curbrk + rest) < 0)
return (void *) -1;
}
}
if (increment == 0)
return __curbrk;
oldbrk = __curbrk;
if (__brk (oldbrk + increment) < 0)
return (void *) -1;
return oldbrk;
}
weak_alias (__sbrk, sbrk)