File: fcall.c

package info (click to toggle)
euslisp 9.31%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 55,448 kB
  • sloc: ansic: 41,610; lisp: 3,339; makefile: 286; sh: 238; asm: 138; python: 53
file content (233 lines) | stat: -rw-r--r-- 7,736 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/****************************************************************/
/* machine dependent compiled code runtime routines
/*	for sun3, sun4 and vax ultrix
/*	1987-Dec-23
/*	Copyright Toshihiro MATSUI
/****************************************************************/
static char *rcsid="@(#)$Id$";

#include "../c/eus.h"

/* 
/* s u n 4 / S P A R C
*/

pointer fcallx(ctx,n,argv,fslot,sym)
register context *ctx;
int n;
pointer *argv,sym;
pointer (**fslot)();
{ eusinteger_t x;
  pointer fn;
  pointer (*subr)();

  fn=getfunc(ctx,sym);

  if (ispointer(fn) && (fn->cix==codecp.cix)) {
#if (WORD_SIZE == 64)
    x= (eusinteger_t)(fn->c.code.entry); x &= ~3L;
#else
    x= (eusinteger_t)(fn->c.code.entry); x &= ~3;
#endif
#if ARM
    if (fn->c.code.entry2 != NIL) {
#if (WORD_SIZE == 64)
      x = x | (intval(fn->c.code.entry2)&0x00000000ffffffff);
#else
      x = x | (intval(fn->c.code.entry2)&0x0000ffff);
#endif
    }
#endif
    subr=(pointer (*)())(x);
    *fslot= subr;
    return((*subr)(ctx,n,argv));
    }
  else return(ufuncall(ctx,sym,sym,(pointer)argv,0,n));}

/*
/*  s u n 3 / M 6 8 0 2 0 
*/

#if sun3 || news || sanyo
pointer fcall(n,argv,sym)
int n;
pointer argv[];
pointer sym;
{ register int *r= &n;
  int x;
  pointer fn,result;
  pointer (*subr)();

  fn=getfunc(sym);

  if (ispointer(fn) && (fn->cix==codecp.cix)) {
    subr=(pointer (*)())
	  ((int)(fn->c.code.codevec)+(intval(fn->c.code.entry)));
    x=r[-1];	/*return addr .i.e. next instruction address to be executed*/
    r=(int *)(x-4);	/*operand for the bsrl inst.*/
    if ((r[-1] & 0x0000ff00) == 0x6100)	*r = (int)subr-x+4; /*bsr.l*/
    else  *r = (int)subr; /*news and SunOS4.0 uses jsr.l instead of bsr.l*/
/* assembler format slightly differs between sun3 and news*/
#if sun3
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
    asm("	cmpl	#0x12345678,d0\n");	/*purge cache*/
#endif
#if news
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
    asm("	cmp.l	#0x12345678,d0");	/*purge cache*/
#endif
#if sanyo
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
    asm("	cmp.l	%d0,&0x12345678");	/*purge cache*/
#endif
    return((*subr)(n,argv)); }
  else return(ufuncall(sym,sym,argv,0,n));}

#endif

/*
/*  V A X
*/

#if vax
pointer fcall(n,argv,sym)
int n;
pointer argv[];
pointer sym;
{ pointer fn;
  pointer (*subr)();
  int *stackframe;
  int *returnaddress;

  fn=getfunc(sym);

  if (ispointer(fn) && (fn->cix==codecp.cix)) {

    subr=(pointer (*)())
	  ((int)(fn->c.code.codevec)
	   +((int)(fn->c.code.entry)>>2));

    stackframe= &n;
    returnaddress=(int *)stackframe[-2];
    returnaddress[-1]=(int)subr-(int)returnaddress;
    fn=(*subr)(n,argv);
    return(fn);    }
  else return(ufuncall(sym,sym,argv,0,n));}

#endif

/*
#if mips && !IRIX
pointer fcall(n,argv,sym)
int n;
register pointer argv[];
register pointer sym;
{ pointer fn;
  pointer (*subr)();

  fn=getfunc(sym);

  if (ispointer(fn) && (fn->cix==codecp.cix)) {

    subr=(pointer (*)())
	  ((int)(fn->c.code.codevec)
	   +((int)(fn->c.code.entry)>>2));

    fn=(*subr)(n,argv);
    return(fn);    }
  else return(ufuncall(sym,sym,argv,0,n));}

#endif
*/