Welcome to mirror list, hosted at ThFree Co, Russian Federation.

syscalls.c « arc « sys « libc « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 107989b00a4bab370ad0a985c996b48f625c8fab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <_ansi.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <reent.h>

_ssize_t
_read_r (struct _reent *r, int fd, void *buf, size_t nbytes)
{
  int err;
  _ssize_t rc;

  SYSCALL (SYS_read, rc, err, fd, buf, nbytes);
  if (err)
    errno = err;
  return rc;
}

_ssize_t
_write_r (struct _reent *r, int fd, const void *buf, size_t nbytes)
{
  int err;
  _ssize_t rc;

  SYSCALL (SYS_write, rc, err, fd, buf, nbytes);
  if (err)
    errno = err;
  return rc;
}

/* FIXME: The prototype in <fcntl.h> for open() uses ...,
   but reent.h uses int.  */

int
_open_r (struct _reent *r, const char *buf, int flags, int mode)
{
  int rc,err;
#if 0
  int mode;
  va_list ap;

  va_start (ap, flags);
  mode = va_arg (ap, int);
  va_end (ap);
#endif

  SYSCALL (SYS_open, rc, err, buf, flags, mode);
  errno = err;
  return rc;
}

int
_close_r (struct _reent *r, int fd)
{
  int rc,err;

  SYSCALL (SYS_close, rc, err, fd, 0, 0);
  if (err)
    errno = err;
  return rc;
}

off_t
_lseek_r (struct _reent *r, int fd,  off_t offset, int whence)
{
  int err;
  off_t rc;

  SYSCALL (SYS_lseek, rc, err, fd, offset, whence);
  if (err)
    errno = err;
  return rc;
}

int
_fstat_r (struct _reent *r, int fd, struct stat *buf)
{
  int rc,err;

  SYSCALL (SYS_fstat, rc, err, fd, buf, 0);
  if (err)
    errno = err;
  return rc;
}

/* FIXME: Shouldn't this be _exit_r?  */

void
_exit (int ret)
{
  int rc,err;

  SYSCALL (SYS_exit, rc, err, ret, 0, 0);

  /* If that failed, use an infinite loop.  */
  while (1)
    continue;
}

time_t
_time (time_t *timer)
{
  return 0;
}

int
_creat_r (struct _reent *r, const char *path, int mode)
{
  return _open_r (r, path, O_CREAT | O_TRUNC, mode);
}

int
_getpid_r (struct _reent *r)
{
  return 42;
}

int
_kill_r (struct _reent *r, int pid, int sig)
{
  int rc,err;

  SYSCALL (SYS_kill, rc, err, pid, sig, 0);
  if (err)
    errno = err;
  return rc;
}