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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [sys/] [arc/] [syscalls.c] - Blame information for rev 262

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

Line No. Rev Author Line
1 148 jeremybenn
#include <sys/types.h>
2
#include <sys/stat.h>
3
#include <sys/syscall.h>
4
#include <_ansi.h>
5
#include <errno.h>
6
#include <fcntl.h>
7
#include <stdarg.h>
8
#include <reent.h>
9
 
10
_ssize_t
11
_read_r (struct _reent *r, int fd, void *buf, size_t nbytes)
12
{
13
  int err;
14
  _ssize_t rc;
15
 
16
  SYSCALL (SYS_read, rc, err, fd, buf, nbytes);
17
  if (err)
18
    __errno_r (r) = err;
19
  return rc;
20
}
21
 
22
_ssize_t
23
_write_r (struct _reent *r, int fd, const void *buf, size_t nbytes)
24
{
25
  int err;
26
  _ssize_t rc;
27
 
28
  SYSCALL (SYS_write, rc, err, fd, buf, nbytes);
29
  if (err)
30
    __errno_r (r) = err;
31
  return rc;
32
}
33
 
34
/* FIXME: The prototype in <fcntl.h> for open() uses ...,
35
   but reent.h uses int.  */
36
 
37
int
38
_open_r (struct _reent *r, const char *buf, int flags, int mode)
39
{
40
  int rc,err;
41
#if 0
42
  int mode;
43
  va_list ap;
44
 
45
  va_start (ap, flags);
46
  mode = va_arg (ap, int);
47
  va_end (ap);
48
#endif
49
 
50
  SYSCALL (SYS_open, rc, err, buf, flags, mode);
51
  if (err)
52
    __errno_r (r) = err;
53
  return rc;
54
}
55
 
56
int
57
_close_r (struct _reent *r, int fd)
58
{
59
  int rc,err;
60
 
61
  SYSCALL (SYS_close, rc, err, fd, 0, 0);
62
  if (err)
63
    __errno_r (r) = err;
64
  return rc;
65
}
66
 
67
off_t
68
_lseek_r (struct _reent *r, int fd,  off_t offset, int whence)
69
{
70
  int err;
71
  off_t rc;
72
 
73
  SYSCALL (SYS_lseek, rc, err, fd, offset, whence);
74
  if (err)
75
    __errno_r (r) = err;
76
  return rc;
77
}
78
 
79
int
80
_fstat_r (struct _reent *r, int fd, struct stat *buf)
81
{
82
  int rc,err;
83
 
84
  SYSCALL (SYS_fstat, rc, err, fd, buf, 0);
85
  if (err)
86
    __errno_r (r) = err;
87
  return rc;
88
}
89
 
90
/* FIXME: Shouldn't this be _exit_r?  */
91
 
92
void
93
_exit (int ret)
94
{
95
  int rc,err;
96
 
97
  SYSCALL (SYS_exit, rc, err, ret, 0, 0);
98
 
99
  /* If that failed, use an infinite loop.  */
100
  while (1)
101
    continue;
102
}
103
 
104
time_t
105
_time (time_t *timer)
106
{
107
  return 0;
108
}
109
 
110
int
111
_creat_r (struct _reent *r, const char *path, int mode)
112
{
113
  return _open_r (r, path, O_CREAT | O_TRUNC, mode);
114
}
115
 
116
int
117
_getpid_r (struct _reent *r)
118
{
119
  return 42;
120
}
121
 
122
int
123
_kill_r (struct _reent *r, int pid, int sig)
124
{
125
  int rc,err;
126
 
127
  SYSCALL (SYS_kill, rc, err, pid, sig, 0);
128
  if (err)
129
    __errno_r (r) = err;
130
  return rc;
131
}

powered by: WebSVN 2.1.0

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