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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [sys/] [arc/] [sbrk.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* sbrk support */
2
 
3
/* The current plan is to have one sbrk handler for all cpus.
4
   Hence use `asm' for each global variable here to avoid the cpu prefix.
5
   We can't intrude on the user's namespace (another reason to use asm).  */
6
 
7
#include <sys/types.h>
8
#include <sys/syscall.h>
9
#include <errno.h>
10
#include <stddef.h>
11
 
12
/* These variables are publicly accessible for debugging purposes.
13
   The user is also free to set sbrk_size to something different.
14
   See mem-layout.c.  */
15
 
16
extern int sbrk_size asm ("sbrk_size");
17
 
18
caddr_t sbrk_start asm ("sbrk_start");
19
caddr_t sbrk_loc asm ("sbrk_loc");
20
 
21
/*caddr_t _sbrk_r (struct _reent *, size_t) asm ("__sbrk_r");*/
22
 
23
/* FIXME: We need a semaphore here.  */
24
 
25
caddr_t
26
_sbrk_r (struct _reent *r, size_t nbytes)
27
{
28
  caddr_t result;
29
 
30
  if (
31
      /* Ensure we don't underflow.  */
32
      sbrk_loc + nbytes < sbrk_start
33
      /* Ensure we don't overflow.  */
34
      || sbrk_loc + nbytes > sbrk_start + sbrk_size)
35
    {
36
      errno = ENOMEM;
37
      return ((caddr_t) -1);
38
    }
39
 
40
  result = sbrk_loc;
41
  sbrk_loc += nbytes;
42
  return result;
43
}

powered by: WebSVN 2.1.0

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