OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [libgloss/] [i386/] [cygmon-salib.c] - Blame information for rev 357

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
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
 
22
extern 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
28
int
29
read (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. */
50
int
51
open (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. */
61
int
62
isatty (int i)
63
{
64
  return i<3;
65
}
66
 
67
int unlink (const char *p)
68
{
69
  return -1;
70
}
71
 
72
 
73
char *
74
sbrk (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
 
91
void
92
_exit(int i)
93
{
94
  while(1) {
95
    __sys_exit (i);
96
    asm("       int $3");
97
  }
98
}
99
 
100
int
101
fstat(int des, struct stat *buf)
102
{
103
  return -1;
104
}
105
 
106
int
107
lseek(int des,unsigned long offset, int whence)
108
{
109
  return -1;
110
}
111
 
112
int
113
getpid ()
114
{
115
  return -1;
116
}
117
 
118
/* Simple replacement for the clock() syscall. */
119
clock_t
120
clock ()
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)
129
typedef void (*ctp)();
130
void
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
 
144
void
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
 
165
void
166
profil_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
}

powered by: WebSVN 2.1.0

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