source: trunk/libs/newlib/src/newlib/libc/reent/sbrkr.c @ 471

Last change on this file since 471 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.1 KB
Line 
1/* Reentrant version of sbrk system call. */
2
3#include <reent.h>
4#include <unistd.h>
5#include <_syslist.h>
6
7/* Some targets provides their own versions of these functions.  Those
8   targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS.  */
9
10#ifdef _REENT_ONLY
11#ifndef REENTRANT_SYSCALLS_PROVIDED
12#define REENTRANT_SYSCALLS_PROVIDED
13#endif
14#endif
15
16#if defined (REENTRANT_SYSCALLS_PROVIDED)
17
18int _dummy_sbrk_syscalls = 1;
19
20#else
21
22/* We use the errno variable used by the system dependent layer.  */
23#undef errno
24extern int errno;
25
26/*
27FUNCTION
28        <<_sbrk_r>>---Reentrant version of sbrk
29       
30INDEX
31        _sbrk_r
32
33SYNOPSIS
34        #include <reent.h>
35        void *_sbrk_r(struct _reent *<[ptr]>, ptrdiff_t <[incr]>);
36
37DESCRIPTION
38        This is a reentrant version of <<sbrk>>.  It
39        takes a pointer to the global data block, which holds
40        <<errno>>.
41*/
42
43void *
44_sbrk_r (struct _reent *ptr,
45     ptrdiff_t incr)
46{
47  char *ret;
48  void *_sbrk(ptrdiff_t);
49
50  errno = 0;
51  if ((ret = (char *)(_sbrk (incr))) == (void *) -1 && errno != 0)
52    ptr->_errno = errno;
53  return ret;
54}
55
56#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
Note: See TracBrowser for help on using the repository browser.