4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-15 11:00:04 +08:00
Jeff Johnston a302b48c21 2001-01-18 Jeff Johnston <jjohnstn@redhat.com>
* libc/sys/arc/Makefile.am: New file.
        * libc/sys/arc/Makefile.in: Ditto.
        * libc/sys/arc/aclocal.m4: Ditto.
        * libc/sys/arc/configure: Ditto.
        * libc/sys/arc/configure.in: Ditto.
        * libc/sys/arc/crt0.S: Ditto.
        * libc/sys/arc/isatty.c: Ditto.
        * libc/sys/arc/mem-layout.c: Ditto.
        * libc/sys/arc/sbrk.c: Ditto.
        * libc/sys/arc/syscalls.c: Ditto.
        * libc/sys/arc/sys/syscall.h: Ditto.
2001-01-19 01:25:13 +00:00

44 lines
1.1 KiB
C

/* sbrk support */
/* The current plan is to have one sbrk handler for all cpus.
Hence use `asm' for each global variable here to avoid the cpu prefix.
We can't intrude on the user's namespace (another reason to use asm). */
#include <sys/types.h>
#include <sys/syscall.h>
#include <errno.h>
#include <stddef.h>
/* These variables are publicly accessible for debugging purposes.
The user is also free to set sbrk_size to something different.
See mem-layout.c. */
extern int sbrk_size asm ("sbrk_size");
caddr_t sbrk_start asm ("sbrk_start");
caddr_t sbrk_loc asm ("sbrk_loc");
/*caddr_t _sbrk_r (struct _reent *, size_t) asm ("__sbrk_r");*/
/* FIXME: We need a semaphore here. */
caddr_t
_sbrk_r (struct _reent *r, size_t nbytes)
{
caddr_t result;
if (
/* Ensure we don't underflow. */
sbrk_loc + nbytes < sbrk_start
/* Ensure we don't overflow. */
|| sbrk_loc + nbytes > sbrk_start + sbrk_size)
{
errno = ENOMEM;
return ((caddr_t) -1);
}
result = sbrk_loc;
sbrk_loc += nbytes;
return result;
}