source: trunk/libs/newlib/src/libgloss/fr30/syscalls.c @ 444

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

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

File size: 1.9 KB
Line 
1/* FR30 system call emulation code
2   Copyright (C) 1998, 2010 Free Software Foundation, Inc.
3   Contributed by Cygnus Solutions.  */
4
5#include <sys/stat.h>
6#include "../syscall.h"
7
8int
9_read (file, ptr, len)
10     int    file;
11     char * ptr;
12     int    len;
13{
14  asm ("ldi:8 %0, r0" :: "i" (SYS_read) : "r0");
15  asm ("int   #10");
16 
17  return;
18}
19
20int
21_lseek (file, ptr, dir)
22     int file;
23     int ptr;
24     int dir;
25{
26  asm ("ldi:8 %0, r0" :: "i" (SYS_lseek) : "r0");
27  asm ("int   #10");
28 
29  return;
30}
31
32int
33_write (file, ptr, len)
34     int    file;
35     char * ptr;
36     int    len;
37{
38  asm ("ldi:8 %0, r0" :: "i" (SYS_write) : "r0");
39  asm ("int   #10");
40 
41  return;
42}
43
44int
45_open (path, flags)
46     const char * path;
47     int flags;
48{
49  asm ("ldi:8  %0, r0" :: "i" (SYS_open) : "r0");
50  asm ("int    #10");
51 
52  return;
53}
54
55int
56_close (file)
57     int file;
58{
59  asm ("ldi:8  %0, r0" :: "i" (SYS_close) : "r0");
60  asm ("int    #10");
61 
62  return 0;
63}
64
65void
66_exit (n)
67     int n;
68{
69  asm ("ldi:8  %0, r0" :: "i" (SYS_exit) : "r0");
70  asm ("int    #10");
71}
72
73
74caddr_t
75_sbrk (incr)
76     int incr;
77{
78  extern char   end asm ("_end");       /* Defined by the linker */
79  extern int    __stack;                /* Defined by linker script.  */
80  static char * heap_end;
81  char *        prev_heap_end;
82
83  if (heap_end == NULL)
84    heap_end = & end;
85 
86  prev_heap_end = heap_end;
87#if 0 
88  if (heap_end + incr > __stack)
89    {
90      _write ( 1, "_sbrk: Heap and stack collision\n", 32);
91      abort ();
92    }
93#endif
94  heap_end += incr;
95
96  return (caddr_t) prev_heap_end;
97}
98
99int
100_fstat (file, st)
101     int file;
102     struct stat * st;
103{
104  st->st_mode = S_IFCHR;
105  return 0;
106}
107
108int
109_unlink ()
110{
111  return -1;
112}
113
114int
115_isatty (fd)
116     int fd;
117{
118  return 0;
119}
120
121int
122_raise ()
123{
124  return 0;
125}
126
127int
128_times ()
129{
130  return 0;
131}
132
133int
134_kill (pid, sig)
135     int pid;
136     int sig;
137{
138  return 0;
139}
140
141int
142_getpid (void)
143{
144  return 0;
145}
Note: See TracBrowser for help on using the repository browser.