source: trunk/libs/newlib/src/libgloss/i386/cygmon-salib.c @ 680

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

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

File size: 3.2 KB
Line 
1/*
2 * Standard x86 syscalls for user programs running under Cygmon
3 *
4 * Copyright (c) 1998, 2000 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
17#include <fcntl.h>
18#include <stdlib.h>
19#include "cygmon-syscall.h"
20#include <sys/time.h>
21
22extern int errno;
23
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
28int
29read (int des, char *dest, int len)
30{
31  return -1;
32}
33#endif
34
35_syscall2(int,kill,int,pid,int,signal);
36
37_syscall2(void,__install_signal_handler,int,arg,void *,handler);
38_syscall1(char **,__get_program_arguments,int *,argc);
39
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, void *,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);
48
49/* Bleah. */
50int
51open (const char *filename, int mode, ...)
52{
53#if 0
54  return __open (filename, mode, 0644);
55#else
56  return -1;
57#endif
58}
59
60/* Ultra-super cheezy. */
61int
62isatty (int i)
63{
64  return i<3;
65}
66
67int unlink (const char *p)
68{
69  return -1;
70}
71
72
73char *
74sbrk (int amt)
75{
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;
83
84  if (((long)ptr) % 8)
85    ptr = ptr + (8 - (((long)(ptr)) % 8));
86  res = ptr;
87  ptr += amt;
88  return (char *)res;
89}
90
91void
92_exit(int i)
93{
94  while(1) {
95    __sys_exit (i);
96    asm("       int $3");
97  }
98}
99
100int
101fstat(int des, struct stat *buf)
102{
103  return -1;
104}
105
106int
107lseek(int des,unsigned long offset, int whence)
108{
109  return -1;
110}
111
112int
113getpid ()
114{
115  return -1;
116}
117
118/* Simple replacement for the clock() syscall. */
119clock_t
120clock ()
121{
122  struct timeval t;
123
124  gettimeofday (&t, 0);
125  return t.tv_sec * 1000 + (t.tv_usec / 1000);
126}
127
128#if ! defined(COFF) && ! defined(AOUT)
129typedef void (*ctp)();
130void
131__do_global_ctors ()
132{
133  extern int __CTOR_LIST__;
134  int *c = &__CTOR_LIST__;
135  c++;
136  while (*c)
137    {
138      ctp d = (ctp)*c;
139      (d)();
140      c++;
141    }
142}
143
144void
145__do_global_dtors ()
146{
147  extern int __DTOR_LIST__;
148  int *c = &__DTOR_LIST__;
149  int *cp = c;
150  c++;
151  while (*c)
152    {
153      c++;
154    }
155  c--;
156  while (c > cp)
157    {
158      ctp d = (ctp)*c;
159      (*d)();
160      c--;
161    }
162}
163#endif
164
165void
166profil_write (int type, char *buffer, int len)
167{
168  static int des = -1;
169
170  if (des < 0)
171    {
172      des = open ("gmon.out", O_WRONLY | O_CREAT | O_TRUNC, 0644);
173    }
174  if (len == 0)
175    {
176      close (des);
177    }
178  else
179    {
180      write (des, buffer, len);
181    }
182}
Note: See TracBrowser for help on using the repository browser.