fixed more binutils issues (newer gcc/libc)
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / sys / arc / syscalls.c
blob107989b00a4bab370ad0a985c996b48f625c8fab
1 #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>
10 _ssize_t
11 _read_r (struct _reent *r, int fd, void *buf, size_t nbytes)
13 int err;
14 _ssize_t rc;
16 SYSCALL (SYS_read, rc, err, fd, buf, nbytes);
17 if (err)
18 errno = err;
19 return rc;
22 _ssize_t
23 _write_r (struct _reent *r, int fd, const void *buf, size_t nbytes)
25 int err;
26 _ssize_t rc;
28 SYSCALL (SYS_write, rc, err, fd, buf, nbytes);
29 if (err)
30 errno = err;
31 return rc;
34 /* FIXME: The prototype in <fcntl.h> for open() uses ...,
35 but reent.h uses int. */
37 int
38 _open_r (struct _reent *r, const char *buf, int flags, int mode)
40 int rc,err;
41 #if 0
42 int mode;
43 va_list ap;
45 va_start (ap, flags);
46 mode = va_arg (ap, int);
47 va_end (ap);
48 #endif
50 SYSCALL (SYS_open, rc, err, buf, flags, mode);
51 errno = err;
52 return rc;
55 int
56 _close_r (struct _reent *r, int fd)
58 int rc,err;
60 SYSCALL (SYS_close, rc, err, fd, 0, 0);
61 if (err)
62 errno = err;
63 return rc;
66 off_t
67 _lseek_r (struct _reent *r, int fd, off_t offset, int whence)
69 int err;
70 off_t rc;
72 SYSCALL (SYS_lseek, rc, err, fd, offset, whence);
73 if (err)
74 errno = err;
75 return rc;
78 int
79 _fstat_r (struct _reent *r, int fd, struct stat *buf)
81 int rc,err;
83 SYSCALL (SYS_fstat, rc, err, fd, buf, 0);
84 if (err)
85 errno = err;
86 return rc;
89 /* FIXME: Shouldn't this be _exit_r? */
91 void
92 _exit (int ret)
94 int rc,err;
96 SYSCALL (SYS_exit, rc, err, ret, 0, 0);
98 /* If that failed, use an infinite loop. */
99 while (1)
100 continue;
103 time_t
104 _time (time_t *timer)
106 return 0;
110 _creat_r (struct _reent *r, const char *path, int mode)
112 return _open_r (r, path, O_CREAT | O_TRUNC, mode);
116 _getpid_r (struct _reent *r)
118 return 42;
122 _kill_r (struct _reent *r, int pid, int sig)
124 int rc,err;
126 SYSCALL (SYS_kill, rc, err, pid, sig, 0);
127 if (err)
128 errno = err;
129 return rc;