fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / reent / sbrkr.c
blobb963307b647da5dca2eb8afea6fc38a237f301ce
1 /* Reentrant version of sbrk system call. */
3 #include <reent.h>
4 #include <unistd.h>
5 #include <_syslist.h>
7 /* Some targets provides their own versions of these functions. Those
8 targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
10 #ifdef _REENT_ONLY
11 #ifndef REENTRANT_SYSCALLS_PROVIDED
12 #define REENTRANT_SYSCALLS_PROVIDED
13 #endif
14 #endif
16 /* If MALLOC_PROVIDED is defined, we don't need this function. */
18 #if defined (REENTRANT_SYSCALLS_PROVIDED) || defined (MALLOC_PROVIDED)
20 int _dummy_sbrk_syscalls = 1;
22 #else
24 /* We use the errno variable used by the system dependent layer. */
25 #undef errno
26 extern int errno;
29 FUNCTION
30 <<_sbrk_r>>---Reentrant version of sbrk
32 INDEX
33 _sbrk_r
35 ANSI_SYNOPSIS
36 #include <reent.h>
37 void *_sbrk_r(struct _reent *<[ptr]>, ptrdiff_t <[incr]>);
39 TRAD_SYNOPSIS
40 #include <reent.h>
41 void *_sbrk_r(<[ptr]>, <[incr]>)
42 struct _reent *<[ptr]>;
43 ptrdiff_t <[incr]>;
45 DESCRIPTION
46 This is a reentrant version of <<sbrk>>. It
47 takes a pointer to the global data block, which holds
48 <<errno>>.
51 void *
52 _DEFUN (_sbrk_r, (ptr, incr),
53 struct _reent *ptr _AND
54 ptrdiff_t incr)
56 char *ret;
57 void *_sbrk(ptrdiff_t);
59 errno = 0;
60 if ((ret = (char *)(_sbrk (incr))) == (void *) -1 && errno != 0)
61 ptr->_errno = errno;
62 return ret;
65 #endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */