source: trunk/libs/newlib/src/libgloss/sparc/cygmon-salib.c @ 450

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

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

File size: 2.6 KB
Line 
1#ifdef TARGET_CPU_SPARC64
2#include <sys/types.h>
3#endif
4#include <sys/time.h>
5
6void
7putTtyChar(int c)
8{
9  /* 2 is fork under solaris; bad juju */
10  asm(" mov %i0,%o0             \n\
11        or %g0,2,%g1            \n\
12        ta 8                    \n\
13        nop");
14}
15
16int
17write(int fd,char *ptr,int amt)
18{
19  if (fd < 0 || fd > 2)
20    {
21      return -1;
22    }
23  asm(" or %g0, 4, %g1          \n\
24        ta 8                    \n\
25        nop");
26  return amt;
27}
28
29int
30read(int fd,char *ptr,int amt)
31{
32  if (fd < 0 || fd > 2)
33    {
34      return -1;
35    }
36  asm(" or %g0, 3, %g1          \n\
37        ta 8                    \n\
38        nop");
39  return amt;
40}
41
42void
43_exit(int code)
44{
45  while(1) {
46    asm(" or %g0,1,%g1          \n\
47          ta 8                  \n\
48          nop                   \n\
49          ta 1                  \n\
50          nop");
51  }
52}
53
54int
55setitimer(int which, const struct itimerval *value, struct itimerval *ovalue)
56{
57  asm(" or %g0, 158, %g1        \n\
58        ta 8                    \n\
59        nop");
60}
61
62
63
64long
65sbrk (unsigned long amt)
66{
67  extern char _end;
68  static char *ptr = 0;
69  char *res;
70  if (ptr == 0)
71    ptr = &_end;
72  if (amt == 0)
73    return (long)ptr;
74
75  if (((long)ptr) % 8)
76    ptr = ptr + (8 - (((long)(ptr)) % 8));
77  res = ptr;
78  ptr += amt;
79  return (long)res;
80}
81
82#ifdef TARGET_CPU_SPARC64
83long
84_sbrk_r (void *foo, unsigned long amt)
85{
86  return sbrk(amt);
87}
88
89long
90_fstat_r (void *foo, void *bar, void *baz)
91{
92  return -1;
93}
94
95long
96_brk_r (void *foo)
97{
98  return sbrk(0);
99}
100
101int
102_open_r (char *filename, int mode)
103{
104  return open (filename, mode);
105}
106
107int
108_close_r (int fd)
109{
110  return close(fd);
111}
112#endif
113
114int
115close (int fd)
116{
117  return 0;
118}
119
120int
121fstat(int des,void *buf)
122{
123  return -1;
124}
125
126int
127lseek(int des,unsigned long offset, int whence)
128{
129  return -1;
130}
131
132int
133isatty(int fd)
134{
135  return (fd < 3);
136}
137
138int
139kill (int pid, int signal)
140{
141  asm ("or %g0, 37, %g1         \n\
142        ta 8                    \n\
143        nop");
144}
145
146int
147getpid ()
148{
149  return -1;
150}
151
152int
153getitimer (int which, struct itimerval *value)
154{
155  asm ("or %g0, 157, %g1        \n\
156        ta 8                    \n\
157        nop");
158}
159
160void
161__install_signal_handler (void *func)
162{
163  asm ("mov %o0, %o1            \n\
164        mov %g0, %o0            \n\
165        or %g0, 48, %g1         \n\
166        ta 8                    \n\
167        nop");
168}
169
170int
171gettimeofday (struct timeval *tp, void *tzp)
172{
173  asm ("or %g0, 156, %g1        \n\
174        ta 8                    \n\
175        nop");
176}
177
178int
179stime (long *seconds)
180{
181  asm ("or %g0, 25, %g1         \n\
182        ta 8                    \n\
183        nop");
184}
185
186int
187add_mapping (long vma, long pma, long size)
188{
189  asm ("or %g0, 115, %g1        \n\
190        ta 8                    \n\
191        nop");
192}
193
194int
195remove_mapping (long vma, long vma_end)
196{
197  asm ("or %g0, 117, %g1        \n\
198        ta 8                    \n\
199        nop");
200}
201
202int
203open (char *filename, int mode)
204{
205  return -1;
206}
207
208void *
209__getProgramArgs (int *argv)
210{
211  int *res;
212
213  /* 184 is tsolsys under solaris; bad juju */
214  asm ("mov %1, %%o0            \n\
215        or %%g0, 184, %%g1      \n\
216        ta 8                    \n\
217        nop                     \n\
218        mov %%o0, %0" : "=r" (res) : "r" (argv): "g1");
219  return res;
220}
Note: See TracBrowser for help on using the repository browser.