Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/tendra5-amd64/src/installers/mips/common/special.c – Rev 5

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/**********************************************************************
32
$Author: release $
33
$Date: 1998/01/17 15:56:06 $
34
$Revision: 1.1.1.1 $
35
$Log: special.c,v $
36
 * Revision 1.1.1.1  1998/01/17  15:56:06  release
37
 * First version to be checked into rolling release.
38
 *
39
 * Revision 1.3  1995/09/12  10:59:43  currie
40
 * gcc pedanttry
41
 *
42
 * Revision 1.2  1995/08/16  16:07:11  currie
43
 * Shortened some .h names
44
 *
45
 * Revision 1.1  1995/04/13  09:08:06  currie
46
 * Initial revision
47
 *
48
***********************************************************************/
49
/*special.c
50
    inlines some of the simpler standard library functions
51
*/
52
 
53
 
54
#include "config.h"
55
#include "expmacs.h"
56
#include "addrtypes.h"
57
#include "shapemacs.h"
58
#include "move.h"
59
#include "psu_ops.h"
60
#include "getregs.h"
61
#include "guard.h"
62
#include "code_here.h"
63
#include "inst_fmt.h"
64
#include "mips_ins.h"
65
#include "labels.h"
66
#include "tags.h"
67
#include "procrectypes.h"
68
#include "bitsmacs.h"
69
#include "common_types.h"
70
#include "special.h"
71
#include "basicread.h"
72
 
73
 
74
int   specno
75
    PROTO_N ( (n) )
76
    PROTO_T ( char *n )
77
{	/* these are the procs I could do
78
				   something about */
79
  if    (strcmp (n, "strcpy") == 0)
80
          return - 1;
81
  if (strcmp (n, "strlen") == 0)
82
    return 2;
83
  if (strcmp (n, "strcmp") == 0)
84
    return - 3;
85
  return 0;
86
}
87
 
88
static  needs strcpyneeds = {
89
  0, 0, 0, 0
90
};
91
static  needs strlenneeds = {
92
  3, 0, uses2_bit, 0
93
};
94
static  needs strcmpneeds = {
95
  2, 0, 0, 0
96
};
97
 
98
needs specialneeds
99
    PROTO_N ( (i) )
100
    PROTO_T ( int i )
101
{	/* these are the needs for their expansion
102
				   */
103
  switch (i) {
104
    case 1:
105
      return strcpyneeds;
106
    case 2:
107
      return strlenneeds;
108
    case 3:
109
      return strcmpneeds;
110
    default:
111
      failer ("not special fn");
112
  }
113
  return strcpyneeds;
114
}
115
 
116
int   specialfn
117
    PROTO_N ( (fn) )
118
    PROTO_T ( exp fn )
119
{	/* could I treat this function load
120
				   specially ? */
121
  if (name (fn) == name_tag && name (son (fn)) == ident_tag &&
122
      isglob (son (fn)) && son (son (fn)) == nilexp) {
123
    char *extname = brog(son (fn)) -> dec_u.dec_val.dec_id;
124
    return specno (extname);
125
  }
126
  return 0;
127
}
128
 
129
 
130
 
131
 
132
 
133
int   specialmake
134
    PROTO_N ( (n, par, sp, dest, exitlab) )
135
    PROTO_T ( int n X exp par X space sp X where dest X int exitlab )
136
{
137
  switch (n) {
138
    case  2:			/* translate strlen in the obvious manner
139
				*/
140
      {
141
	where w;
142
	ans aa;
143
	int   lstart = new_label ();
144
	int   r;
145
	int   r1;
146
	baseoff ind3;
147
	int r3;
148
	r = (dest.answhere.discrim == inreg) ? regalt (dest.answhere)
149
	  : getreg (sp.fixed);
150
	if (r == 0) r = 2; /* can be called like proc on lhs of ass */
151
	sp = guardreg(r,sp);
152
	r3 = getreg(sp.fixed);
153
	ind3.base = r3; ind3.offset = 0;
154
	setregalt (w.answhere, r3);
155
	w.ashwhere = ashof (sh (par));
156
	code_here (par, sp, w);
157
 
158
	r1 = getreg (guardreg (r3, sp).fixed);
159
 
160
	rri_ins (i_add, r, r3, 1);
161
	set_label (lstart);
162
 
163
	ls_ins (i_lb, r1, ind3);
164
	rri_ins (i_add, r3, r3, 1);
165
	condr_ins (i_bnez, r1, lstart);
166
 
167
	rrr_ins (i_sub, r, r3, r);
168
	setregalt (aa, r);
169
	move (aa, dest, sp, 1);
170
	return exitlab;
171
      }
172
    default:
173
      failer ("not special");
174
  }
175
  return exitlab;
176
}