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

syscalls.c « d30v « libgloss - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b55bb629a09c3b1164a0b5c528d44e0e7c545849 (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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
 * syscalls.c -- provide system call support via trap 31
 *
 * Copyright (c) 1997 Cygnus Support
 *
 * The authors hereby grant permission to use, copy, modify, distribute,
 * and license this software and its documentation for any purpose, provided
 * that existing copyright notices are retained in all copies and that this
 * notice is included verbatim in any distributions. No written agreement,
 * license, or royalty fee is required for any of the authorized uses.
 * Modifications to this software may be copyrighted by their authors
 * and need not follow the licensing terms described here, provided that
 * the new terms are clearly indicated on the first page of each file where
 * they apply.
 *
 * Read bytes, using simulator trap 31.
 */

#include <stdlib.h>
#include <time.h>
#include "syscall.h"

extern int *__errno(), errno;

__asm__ (
"	.globl	__syscall					\n\
	.type	__syscall,@function				\n\
__syscall:							\n\
	trap	31		|| nop				\n\
	cmpge	f0,r2,0		-> jmp/tx	link		\n\
	bra	__set_errno					\n\
	.size	__syscall,.-__syscall				\n\
");

int
__set_errno (int new_errno)
{
  errno = new_errno;
  *(__errno)() = errno;
  return -1;
}

void
_exit (int status)
{
  __syscall (status, 0, 0, 0, SYS_exit);
}

int
open (const char *filename, int flags, int mode)
{
  return __syscall (filename, flags, mode, 0, SYS_open);
}

int
close (int filedes)
{
  return __syscall (filedes, 0, 0, 0, SYS_close);
}

int
read (int filedes, void *buffer, size_t length)
{
  return __syscall (filedes, buffer, length, 0, SYS_read);
}

int
write (int filedes, void *buffer, size_t length)
{
  return __syscall (filedes, buffer, length, 0, SYS_write);
}

long
lseek (int filedes, long offset, int whence)
{
  return __syscall (filedes, offset, whence, 0, SYS_lseek);
}

int
unlink (const char *filename)
{
  return __syscall (filename, 0, 0, 0, SYS_unlink);
}

int
getpid (void)
{
  return __syscall (0, 0, 0, 0, SYS_getpid);
}

int
kill (int signal, int pid)
{
  return __syscall (signal, pid, 0, 0, SYS_kill);
}

int
fstat (int filedes, void *info)
{
  return __syscall (filedes, info, 0, 0, SYS_fstat);
}

int
__argvlen (void)
{
  return __syscall (0, 0, 0, 0, SYS_argvlen);
}

int
__argv (void)
{
  return __syscall (0, 0, 0, 0, SYS_argv);
}

int
chdir (char *dir)
{
  return __syscall (dir, 0, 0, 0, SYS_chdir);
}

int
stat (const char *filename, void *info)
{
  return __syscall (filename, info, 0, 0, SYS_stat);
}

int
chmod (const char *filename, int mode)
{
  return __syscall (filename, mode, 0, 0, SYS_chmod);
}

int
utime (const char *filename, void *packet)
{
  return __syscall (filename, packet, 0, 0, SYS_utime);
}

time_t
time (time_t *time_ptr)
{
  time_t result;	
  result = (time_t) __syscall (time_ptr, 0, 0, 0, SYS_time);
  if (time_ptr != NULL)
    *time_ptr = result;
  return result;
}