fixed more binutils issues (newer gcc/libc)
[zpugcc/jano.git] / toolchain / gcc / libgloss / i386 / cygmon-salib.c
blob466045d0785fa5c9056d1b45b5e5ba6bf5a89ae7
1 /*
2 * Standard x86 syscalls for user programs running under Cygmon
4 * Copyright (c) 1998, 2000 Cygnus Support
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.
17 #include <fcntl.h>
18 #include <stdlib.h>
19 #include "cygmon-syscall.h"
20 #include <sys/time.h>
22 extern int errno;
24 _syscall3(int,write,int,i,char *,c,int,len);
25 #if 0
26 _syscall3(int,read,int,i,char *,c,int,len);
27 #else
28 int
29 read (int des, char *dest, int len)
31 return -1;
33 #endif
35 _syscall2(int,kill,int,pid,int,signal);
37 _syscall2(void,__install_signal_handler,int,arg,void *,handler);
38 _syscall1(char **,__get_program_arguments,int *,argc);
40 _syscall1(void,__sys_exit,int,exitcode);
41 _syscall1(void,putTtyChar,int,character);
42 _syscall1(time_t,time,time_t *,ptr);
43 _syscall2(int, gettimeofday, struct timeval *,time, struct timezone *,z);
44 _syscall3(int, __open, const char *, filename, int, mode, int, filemode);
45 _syscall4(void, profil, unsigned short *, buff, unsigned int, bufsiz,
46 unsigned int, offset, unsigned int, scale);
47 _syscall1(int, close, int, fd);
49 /* Bleah. */
50 int
51 open (const char *filename, int mode, ...)
53 #if 0
54 return __open (filename, mode, 0644);
55 #else
56 return -1;
57 #endif
60 /* Ultra-super cheezy. */
61 int
62 isatty (int i)
64 return i<3;
67 int unlink (const char *p)
69 return -1;
73 char *
74 sbrk (int amt)
76 extern char _end;
77 static char *ptr = 0;
78 char *res;
79 if (ptr == 0)
80 ptr = &_end;
81 if (amt == 0)
82 return (char *)ptr;
84 if (((long)ptr) % 8)
85 ptr = ptr + (8 - (((long)(ptr)) % 8));
86 res = ptr;
87 ptr += amt;
88 return (char *)res;
91 void
92 _exit(int i)
94 while(1) {
95 __sys_exit (i);
96 asm(" int $3");
101 fstat(int des, struct stat *buf)
103 return -1;
107 lseek(int des,unsigned long offset, int whence)
109 return -1;
113 getpid ()
115 return -1;
118 /* Simple replacement for the clock() syscall. */
119 clock_t
120 clock ()
122 struct timeval t;
124 gettimeofday (&t, 0);
125 return t.tv_sec * 1000 + (t.tv_usec / 1000);
128 #if ! defined(COFF) && ! defined(AOUT)
129 typedef void (*ctp)();
130 void
131 __do_global_ctors ()
133 extern int __CTOR_LIST__;
134 int *c = &__CTOR_LIST__;
135 c++;
136 while (*c)
138 ctp d = (ctp)*c;
139 (d)();
140 c++;
144 void
145 __do_global_dtors ()
147 extern int __DTOR_LIST__;
148 int *c = &__DTOR_LIST__;
149 int *cp = c;
150 c++;
151 while (*c)
153 c++;
155 c--;
156 while (c > cp)
158 ctp d = (ctp)*c;
159 (*d)();
160 c--;
163 #endif
165 void
166 profil_write (int type, char *buffer, int len)
168 static int des = -1;
170 if (des < 0)
172 des = open ("gmon.out", O_WRONLY | O_CREAT | O_TRUNC, 0644);
174 if (len == 0)
176 close (des);
178 else
180 write (des, buffer, len);