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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [newlib/] [newlib/] [libc/] [reent/] [sbrkr.c] - Blame information for rev 39

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
/* Reentrant versions of sbrk system call.  This implementation just
2
   calls the stat system call.  */
3
 
4
#include <reent.h>
5
#include <unistd.h>
6
#include <_syslist.h>
7
 
8
/* Some targets provides their own versions of these functions.  Those
9
   targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS.  */
10
 
11
#ifdef _REENT_ONLY
12
#ifndef REENTRANT_SYSCALLS_PROVIDED
13
#define REENTRANT_SYSCALLS_PROVIDED
14
#endif
15
#endif
16
 
17
/* If MALLOC_PROVIDED is defined, we don't need this function.  */
18
 
19
#if defined (REENTRANT_SYSCALLS_PROVIDED) || defined (MALLOC_PROVIDED)
20
 
21
int _dummy_sbrk_syscalls = 1;
22
 
23
#else
24
 
25
/* We use the errno variable used by the system dependent layer.  */
26
#undef errno
27
int errno;
28
 
29
/*
30
FUNCTION
31
        <<_sbrk_r>>---Reentrant version of sbrk
32
 
33
INDEX
34
        _sbrk_r
35
 
36
ANSI_SYNOPSIS
37
        #include <reent.h>
38
        void *_sbrk_r(struct _reent *<[ptr]>, size_t <[incr]>);
39
 
40
TRAD_SYNOPSIS
41
        #include <reent.h>
42
        void *_sbrk_r(<[ptr]>, <[incr]>)
43
        struct _reent *<[ptr]>;
44
        size_t <[incr]>;
45
 
46
DESCRIPTION
47
        This is a reentrant version of <<sbrk>>.  It
48
        takes a pointer to the global data block, which holds
49
        <<errno>>.
50
*/
51
 
52
void *
53
_sbrk_r (ptr, incr)
54
     struct _reent *ptr;
55
     size_t incr;
56
{
57
  char *ret;
58
  void *_sbrk(size_t);
59
 
60
  errno = 0;
61
  if ((ret = (char *)(_sbrk (incr))) == (void *) -1 && errno != 0)
62
    ptr->_errno = errno;
63
  return ret;
64
}
65
 
66
#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.