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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* syscalls.c - non-trap system calls for D10V
2
 *
3
 * This file contains system calls that cannot be implemented with
4
 * a simple "trap 15" instruction.  The ones that can are in trap.S.
5
 */
6
 
7
#include <_ansi.h>
8
#include <sys/types.h>
9
#include <sys/stat.h>
10
#include <errno.h>
11
#undef  errno
12
 
13
void _exit (int n);     /* in trap.S */
14
 
15
extern int _write (int fd, const void *ptr, size_t len);
16
 
17
int errno;
18
 
19
register char *stack_ptr asm ("sp");
20
 
21
caddr_t
22
_sbrk (int incr)
23
{
24
  extern char end;              /* Defined by the linker */
25
  static char *heap_end;
26
  char *prev_heap_end;
27
  char *sp = (char *)stack_ptr;
28
 
29
  if (heap_end == 0)
30
    {
31
      heap_end = (char *)((((unsigned short) &end) + 7) & ~7);
32
    }
33
  prev_heap_end = heap_end;
34
  if (heap_end + incr > sp)
35
    {
36
      _write (2, "Heap and stack collision\n", sizeof ("Heap and stack collision\n")-1);
37
      abort ();
38
    }
39
  heap_end += incr;
40
  if ((unsigned short)heap_end > 0xbfff
41
      || (heap_end < prev_heap_end && incr > 0)
42
      || (heap_end < (char *)((((unsigned short) &end) + 7) & ~7)))
43
    {
44
      _write (2, "Too much memory was allocated\n", sizeof ("Too much memory was allocated\n")-1);
45
      abort ();
46
    }
47
 
48
  return (caddr_t) prev_heap_end;
49
}
50
 
51
int
52
_fstat (int file,
53
        struct stat *st)
54
{
55
  st->st_mode = S_IFCHR;
56
  return 0;
57
}
58
 
59
int
60
_unlink ()
61
{
62
  errno = ENOSYS;
63
  return -1;
64
}
65
 
66
int
67
_isatty (int fd)
68
{
69
  return 1;
70
}
71
 
72
void
73
_raise ()
74
{
75
}
76
 
77
/* If this library is compiled with -mint32, provide conversion functions for
78
   the system call traps.  */
79
 
80
#if __INT__==32
81
extern short _read16 (short fd, void *ptr, short len);
82
int
83
_read (int fd, void *ptr, size_t len)
84
{
85
  return _read16 ((short)fd, ptr, (short)len);
86
}
87
 
88
extern short _write16 (short fd, const void *ptr, short len);
89
int
90
_write (int fd, const void *ptr, size_t len)
91
{
92
  return _write16 ((short)fd, ptr, (short)len);
93
}
94
 
95
extern short _lseek16 (short fd, long offset, short whence);
96
int
97
_lseek (int fd, off_t offset, int whence)
98
{
99
  return _lseek16 ((short)fd, offset, (short)whence);
100
}
101
 
102
extern short _close16 (short fd);
103
int
104
_close (int fd)
105
{
106
  return _close16 ((short)fd);
107
}
108
 
109
extern short _open16 (const char *name, short flags, short mode);
110
int
111
_open (const char *name, int flags, mode_t mode)
112
{
113
  return _open16 (name, (short)flags, (short)mode);
114
}
115
 
116
extern short _creat16 (const char *name, mode_t mode);
117
int
118
_creat (const char *name, mode_t mode)
119
{
120
  return _creat16 (name, mode);
121
}
122
 
123
extern void _exit16 (short status);
124
void
125
_exit (int status)
126
{
127
  _exit16 ((short)status);
128
}
129
 
130
extern short _stat16 (const char *name, struct stat *stat_pkt);
131
int
132
_stat (const char *name, struct stat *stat_pkt)
133
{
134
  return _stat16 (name, stat_pkt);
135
}
136
 
137
extern short _chmod16 (const char *name, short mode);
138
int
139
_chmod (const char *name, mode_t mode)
140
{
141
  return _chmod16 (name, (short)mode);
142
}
143
 
144
extern short _chown16 (const char *name, short uid, short gid);
145
int
146
_chown (const char *name, uid_t uid, gid_t gid)
147
{
148
  return _chown16 (name, (short)uid, (short)gid);
149
}
150
 
151
extern short _fork16 (void);
152
int
153
_fork (void)
154
{
155
  return _fork16 ();
156
}
157
 
158
extern short _wait16 (short *status);
159
int
160
_wait (int *status)
161
{
162
  if (status)
163
    {
164
      short status16;
165
      short ret = _wait16 (&status16);
166
      if (ret >= 0)
167
        *status = status16;
168
      return ret;
169
    }
170
  else
171
    return _wait16 ((short *)0);
172
}
173
 
174
extern short _execve16 (const char *filename, const char *argv [], const char *envp[]);
175
int
176
_execve (const char *filename, const char *argv [], const char *envp[])
177
{
178
  return _execve16 (filename, argv, envp);
179
}
180
 
181
extern short _execv16 (const char *filename, const char *argv []);
182
int
183
_execv (const char *filename, const char *argv [])
184
{
185
  return _execv16 (filename, argv);
186
}
187
 
188
extern short _pipe16 (short fds[]);
189
int
190
_pipe (int fds[])
191
{
192
  short fds16[2];
193
  short ret = _pipe16 (fds16);
194
  if (ret >= 0)
195
    {
196
      fds[0] = fds16[0];
197
      fds[1] = fds16[1];
198
    }
199
 
200
  return ret;
201
}
202
 
203
extern short _getpid16 (void);
204
int
205
_getpid (void)
206
{
207
  return _getpid16 ();
208
}
209
 
210
extern short _kill16 (short pid, short sig);
211
int
212
_kill (int pid, int sig)
213
{
214
  return _kill16 ((short)pid, (short)sig);
215
}
216
#endif

powered by: WebSVN 2.1.0

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