OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [reent/] [sbrkr.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1010 ivang
/* 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 MALLOC_PROVIDED is defined, we don't need this function.  */
17
 
18
#if defined (REENTRANT_SYSCALLS_PROVIDED) || defined (MALLOC_PROVIDED)
19
 
20
int _dummy_sbrk_syscalls = 1;
21
 
22
#else
23
 
24
/* We use the errno variable used by the system dependent layer.  */
25
#undef errno
26
extern int errno;
27
 
28
/*
29
FUNCTION
30
        <<_sbrk_r>>---Reentrant version of sbrk
31
 
32
INDEX
33
        _sbrk_r
34
 
35
ANSI_SYNOPSIS
36
        #include <reent.h>
37
        void *_sbrk_r(struct _reent *<[ptr]>, size_t <[incr]>);
38
 
39
TRAD_SYNOPSIS
40
        #include <reent.h>
41
        void *_sbrk_r(<[ptr]>, <[incr]>)
42
        struct _reent *<[ptr]>;
43
        size_t <[incr]>;
44
 
45
DESCRIPTION
46
        This is a reentrant version of <<sbrk>>.  It
47
        takes a pointer to the global data block, which holds
48
        <<errno>>.
49
*/
50
 
51
void *
52
_sbrk_r (ptr, incr)
53
     struct _reent *ptr;
54
     size_t incr;
55
{
56
  char *ret;
57
  void *_sbrk(size_t);
58
 
59
  errno = 0;
60
  if ((ret = (char *)(_sbrk (incr))) == (void *) -1 && errno != 0)
61
    ptr->_errno = errno;
62
  return ret;
63
}
64
 
65
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.