source: trunk/libs/newlib/src/libgloss/or1k/syscalls.c @ 476

Last change on this file since 476 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.9 KB
Line 
1/* syscalls.c -- reentrant syscalls for OpenRISC 1000.
2 *
3 * Copyright (c) 2011, 2014 Authors
4 *
5 * Contributor Julius Baxter <juliusbaxter@gmail.com>
6 * Contributor Stefan Wallentowitz <stefan.wallentowitz@tum.de>
7 *
8 * The authors hereby grant permission to use, copy, modify, distribute,
9 * and license this software and its documentation for any purpose, provided
10 * that existing copyright notices are retained in all copies and that this
11 * notice is included verbatim in any distributions. No written agreement,
12 * license, or royalty fee is required for any of the authorized uses.
13 * Modifications to this software may be copyrighted by their authors
14 * and need not follow the licensing terms described here, provided that
15 * the new terms are clearly indicated on the first page of each file where
16 * they apply.
17 */
18
19#include <errno.h>
20#include <reent.h>
21#include <sys/types.h>
22#include <sys/stat.h>
23#include <sys/time.h>
24#include "board.h"
25
26/* Write is actually the only thing we provide. All other are stubs.. */
27
28extern void _or1k_outbyte(char c);
29
30_ssize_t
31_write_r(struct _reent * reent, int fd, const void *buf, size_t nbytes)
32{
33        int i;
34        char* b = (char*) buf;
35
36        for (i = 0; i < nbytes; i++) {
37                if (*(b + i) == '\n') {
38                        _or1k_outbyte ('\r');
39                }
40                _or1k_outbyte (*(b + i));
41        }
42        return (nbytes);
43}
44
45void
46_exit(int rc)
47{
48        _or1k_board_exit();
49        while (1) {}
50}
51
52int
53_close_r(struct _reent *reent, int fildes)
54{
55        reent->_errno = ENOSYS;
56        return -1;
57}
58
59int
60_execve_r(struct _reent *reent, const char *name, char * const *argv,
61                char * const *env)
62{
63        reent->_errno = ENOSYS;
64        return -1;
65}
66
67int
68_fork_r(struct _reent *reent)
69{
70        errno = ENOSYS;
71        return -1;
72}
73
74int
75_fstat_r(struct _reent *reent, int fildes, struct stat *st)
76{
77        reent->_errno = ENOSYS;
78        return -1;
79}
80
81int
82_getpid_r(struct _reent *reent)
83{
84        reent->_errno = ENOSYS;
85        return -1;
86}
87
88int
89_gettimeofday(struct _reent *reent, struct timeval  *ptimeval, void *ptimezone)
90{
91        reent->_errno = ENOSYS;
92        return -1;
93}
94
95int
96_isatty_r(struct _reent *reent, int file)
97{
98        reent->_errno = ENOSYS;
99        return 0;
100}
101
102int
103_kill_r(struct _reent *reent, int pid, int sig)
104{
105        reent->_errno = ENOSYS;
106        return -1;
107}
108
109int
110_link_r(struct _reent *reent, const char *existing, const char *new)
111{
112        reent->_errno = ENOSYS;
113        return -1;
114}
115
116_off_t
117_lseek_r(struct _reent *reent, int file, _off_t ptr, int dir)
118{
119        errno = ENOSYS;
120        return -1;
121}
122
123int
124_open_r(struct _reent *reent, const char *file, int flags, int mode)
125{
126        reent->_errno = ENOSYS;
127        return -1;
128}
129
130_ssize_t
131_read_r(struct _reent *reent, int file, void *ptr, size_t len)
132{
133        reent->_errno = ENOSYS;
134        return -1;
135}
136
137int
138_readlink_r(struct _reent *reent, const char *path, char *buf, size_t bufsize)
139{
140        reent->_errno = ENOSYS;
141        return -1;
142}
143
144int
145_stat_r(struct _reent *reent, const char *path, struct stat *buf)
146{
147        reent->_errno = EIO;
148        return -1;
149}
150
151int
152_unlink_r(struct _reent *reent, const char * path)
153{
154        reent->_errno = EIO;
155        return (-1);
156}
157
Note: See TracBrowser for help on using the repository browser.