OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [newlib/] [newlib/] [libgloss/] [i386/] [cygmon-salib.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 56 joel
/*
2
 * Standard x86 syscalls for user programs running under Cygmon
3
 *
4
 * Copyright (c) 1998 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
 
22
extern int errno;
23
 
24
_syscall3(int,write,int,i,char *,c,int,len);
25
 
26
_syscall3(int,read,int,i,char *,c,int,len);
27
 
28
_syscall2(int,kill,int,pid,int,signal);
29
 
30
_syscall2(void,__install_signal_handler,int,arg,void *,handler);
31
_syscall1(char **,__get_program_arguments,int *,argc);
32
 
33
_syscall1(void,__sys_exit,int,exitcode);
34
_syscall1(void,putTtyChar,int,character);
35
_syscall1(time_t,time,time_t *,ptr);
36
_syscall2(int, gettimeofday, struct timeval *,time, struct timezone *,z);
37
_syscall3(int, __open, const char *, filename, int, mode, int, filemode);
38
_syscall4(void, profil, unsigned short *, buff, unsigned int, bufsiz,
39
          unsigned int, offset, unsigned int, scale);
40
_syscall1(int, close, int, fd);
41
 
42
/* Bleah. */
43
int
44
open (const char *filename, int mode, ...)
45
{
46
  return __open (filename, mode, 0644);
47
}
48
 
49
/* Ultra-super cheezy. */
50
int
51
isatty (int i)
52
{
53
  return i<3;
54
}
55
 
56
char *
57
sbrk (int amt)
58
{
59
  extern char _end;
60
  static char *ptr = 0;
61
  char *res;
62
  if (ptr == 0)
63
    ptr = &_end;
64
  if (amt == 0)
65
    return (char *)ptr;
66
 
67
  if (((long)ptr) % 8)
68
    ptr = ptr + (8 - (((long)(ptr)) % 8));
69
  res = ptr;
70
  ptr += amt;
71
  return (char *)res;
72
}
73
 
74
void
75
_exit(int i)
76
{
77
  while(1) {
78
    __sys_exit (i);
79
    asm("       int $3");
80
  }
81
}
82
 
83
int
84
fstat(int des, struct stat *buf)
85
{
86
  return -1;
87
}
88
 
89
int
90
lseek(int des,unsigned long offset, int whence)
91
{
92
  return -1;
93
}
94
 
95
int
96
getpid ()
97
{
98
  return -1;
99
}
100
 
101
/* Simple replacement for the clock() syscall. */
102
clock_t
103
clock ()
104
{
105
  struct timeval t;
106
 
107
  gettimeofday (&t, 0);
108
  return t.tv_sec * 1000 + (t.tv_usec / 1000);
109
}
110
 
111
#ifndef COFF
112
typedef void (*ctp)();
113
void
114
__do_global_ctors ()
115
{
116
  extern int __CTOR_LIST__;
117
  int *c = &__CTOR_LIST__;
118
  c++;
119
  while (*c)
120
    {
121
      ctp d = (ctp)*c;
122
      (d)();
123
      c++;
124
    }
125
}
126
 
127
void
128
__do_global_dtors ()
129
{
130
  extern int __DTOR_LIST__;
131
  int *c = &__DTOR_LIST__;
132
  int *cp = c;
133
  c++;
134
  while (*c)
135
    {
136
      c++;
137
    }
138
  c--;
139
  while (c > cp)
140
    {
141
      ctp d = (ctp)*c;
142
      (*d)();
143
      c--;
144
    }
145
}
146
#endif
147
 
148
void
149
profil_write (int type, char *buffer, int len)
150
{
151
  static int des = -1;
152
 
153
  if (des < 0)
154
    {
155
      des = open ("gmon.out", O_WRONLY | O_CREAT | O_TRUNC, 0644);
156
    }
157
  if (len == 0)
158
    {
159
      close (des);
160
    }
161
  else
162
    {
163
      write (des, buffer, len);
164
    }
165
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.