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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [libgloss/] [d30v/] [syscalls.c] - Blame information for rev 868

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

Line No. Rev Author Line
1 148 jeremybenn
/*
2
 * syscalls.c -- provide system call support via trap 31
3
 *
4
 * Copyright (c) 1997 Cygnus Support
5
 *
6
 * The authors hereby grant permission to use, copy, modify, distribute,
7
 * and license this software and its documentation for any purpose, provided
8
 * that existing copyright notices are retained in all copies and that this
9
 * notice is included verbatim in any distributions. No written agreement,
10
 * license, or royalty fee is required for any of the authorized uses.
11
 * Modifications to this software may be copyrighted by their authors
12
 * and need not follow the licensing terms described here, provided that
13
 * the new terms are clearly indicated on the first page of each file where
14
 * they apply.
15
 *
16
 * Read bytes, using simulator trap 31.
17
 */
18
 
19
#include <stdlib.h>
20
#include <time.h>
21
#include "syscall.h"
22
 
23
extern int *__errno(), errno;
24
 
25
__asm__ (
26
"       .globl  __syscall                                       \n\
27
        .type   __syscall,@function                             \n\
28
__syscall:                                                      \n\
29
        trap    31              || nop                          \n\
30
        cmpge   f0,r2,0         -> jmp/tx       link            \n\
31
        bra     __set_errno                                     \n\
32
        .size   __syscall,.-__syscall                           \n\
33
");
34
 
35
int
36
__set_errno (int new_errno)
37
{
38
  errno = new_errno;
39
  *(__errno)() = errno;
40
  return -1;
41
}
42
 
43
void
44
_exit (int status)
45
{
46
  __syscall (status, 0, 0, 0, SYS_exit);
47
}
48
 
49
int
50
open (const char *filename, int flags, int mode)
51
{
52
  return __syscall (filename, flags, mode, 0, SYS_open);
53
}
54
 
55
int
56
close (int filedes)
57
{
58
  return __syscall (filedes, 0, 0, 0, SYS_close);
59
}
60
 
61
int
62
read (int filedes, void *buffer, size_t length)
63
{
64
  return __syscall (filedes, buffer, length, 0, SYS_read);
65
}
66
 
67
int
68
write (int filedes, void *buffer, size_t length)
69
{
70
  return __syscall (filedes, buffer, length, 0, SYS_write);
71
}
72
 
73
long
74
lseek (int filedes, long offset, int whence)
75
{
76
  return __syscall (filedes, offset, whence, 0, SYS_lseek);
77
}
78
 
79
int
80
unlink (const char *filename)
81
{
82
  return __syscall (filename, 0, 0, 0, SYS_unlink);
83
}
84
 
85
int
86
getpid (void)
87
{
88
  return __syscall (0, 0, 0, 0, SYS_getpid);
89
}
90
 
91
int
92
kill (int signal, int pid)
93
{
94
  return __syscall (signal, pid, 0, 0, SYS_kill);
95
}
96
 
97
int
98
fstat (int filedes, void *info)
99
{
100
  return __syscall (filedes, info, 0, 0, SYS_fstat);
101
}
102
 
103
int
104
__argvlen (void)
105
{
106
  return __syscall (0, 0, 0, 0, SYS_argvlen);
107
}
108
 
109
int
110
__argv (void)
111
{
112
  return __syscall (0, 0, 0, 0, SYS_argv);
113
}
114
 
115
int
116
chdir (char *dir)
117
{
118
  return __syscall (dir, 0, 0, 0, SYS_chdir);
119
}
120
 
121
int
122
stat (const char *filename, void *info)
123
{
124
  return __syscall (filename, info, 0, 0, SYS_stat);
125
}
126
 
127
int
128
chmod (const char *filename, int mode)
129
{
130
  return __syscall (filename, mode, 0, 0, SYS_chmod);
131
}
132
 
133
int
134
utime (const char *filename, void *packet)
135
{
136
  return __syscall (filename, packet, 0, 0, SYS_utime);
137
}
138
 
139
time_t
140
time (time_t *time_ptr)
141
{
142
  time_t result;
143
  result = (time_t) __syscall (time_ptr, 0, 0, 0, SYS_time);
144
  if (time_ptr != NULL)
145
    *time_ptr = result;
146
  return result;
147
}

powered by: WebSVN 2.1.0

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