[go: up one dir, main page]

File: util.m4.c

package info (click to toggle)
sablevm 1.11.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,980 kB
  • ctags: 7,922
  • sloc: ansic: 116,013; sh: 8,679; makefile: 489
file content (204 lines) | stat: -rw-r--r-- 4,522 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
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * This source file is part of SableVM.                            *
 *                                                                 *
 * See the file "LICENSE" for the copyright information and for    *
 * the terms and conditions for copying, distribution and          *
 * modification of this source file.                               *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
----------------------------------------------------------------------
m4svm_array_element
----------------------------------------------------------------------
*/

/*
 * This macro can be multi-called.
 * m4svm_multicall(m4svm_array_element)
 */

m4svm_define_begin v = ":], [:m4svm_array_element:])";

/*
-----------------------------------m4_dnl
-----------------------------------
_svmf_get_$1_array_element
-----------------------------------m4_dnl
-----------------------------------
*/

inline static j$1
_svmf_get_$1_array_element (_svmt_array_instance *array, jint indx)
{
  j$1 *elements;

#ifndef _SABLEVM_INLINED_THREADED_INTERPRETER
  assert (array != NULL);
  assert (array->vtable->type->is_array);
  assert (indx >= 0 && indx < array->size);
#endif

  elements = (j$1 *) (void *)
    (((char *) array) + _svmf_aligned_size_t (sizeof (_svmt_array_instance)));

  return elements[indx];
}

/*
-----------------------------------m4_dnl
-----------------------------------
_svmf_set_$1_array_element
-----------------------------------m4_dnl
-----------------------------------
*/

inline static void
_svmf_set_$1_array_element (_svmt_array_instance *array, jint indx, j$1 value)
{
  j$1 *elements;

#ifndef _SABLEVM_INLINED_THREADED_INTERPRETER
  assert (array != NULL);
  assert (array->vtable->type->is_array);
  assert (indx >= 0 && indx < array->size);
#endif

  elements = (j$1 *) (void *)
    (((char *) array) + _svmf_aligned_size_t (sizeof (_svmt_array_instance)));

  elements[indx] = value;
}

m4svm_define_end v = ":])";

/*
----------------------------------------------------------------------
m4svm_getset_field
----------------------------------------------------------------------
*/

/*
 * This macro can be multi-called.
 * m4svm_multicall(m4svm_getset_field)
 */

m4svm_define_begin v = ":], [:m4svm_getset_field:])";

/*
-----------------------------------m4_dnl
-----------------------------------
_svmf_get_$1_field
-----------------------------------m4_dnl
-----------------------------------
*/

inline static $2
_svmf_get_$1_field (_svmt_object_instance *instance, size_t offset)
{
  return *(($2 *) (void *) (((char *) instance) + offset));
}

/*
-----------------------------------m4_dnl
-----------------------------------
_svmf_put_$1_field
-----------------------------------m4_dnl
-----------------------------------
*/

inline static void
_svmf_put_$1_field (_svmt_object_instance *instance, size_t offset, $2 value)
{
  *(($2 *) (void *) (((char *) instance) + offset)) = value;
}

m4svm_define_end v = ":])";

/*
----------------------------------------------------------------------
m4svm_getset_static
----------------------------------------------------------------------
*/

/*
 * This macro can be multi-called.
 * m4svm_multicall(m4svm_getset_static)
 */

m4svm_define_begin v = ":], [:m4svm_getset_static:])";

/*
-----------------------------------m4_dnl
-----------------------------------
_svmf_get_$1_static
-----------------------------------m4_dnl
-----------------------------------
*/

inline static $2
_svmf_get_$1_static (jvalue *pvalue)
{
  return pvalue->$3;
}

/*
-----------------------------------m4_dnl
-----------------------------------
_svmf_put_$1_static
-----------------------------------m4_dnl
-----------------------------------
*/

inline static void
_svmf_put_$1_static (jvalue *pvalue, $2 value)
{
  pvalue->$3 = value;
}

m4svm_define_end v = ":])";

/*
----------------------------------------------------------------------
head
----------------------------------------------------------------------

m4svm_file_name

m4svm_array_element_begin[:

byte
char
short
int
long
float
double

:]m4svm_array_element_end

m4svm_getset_field_begin[:

BYTE, jbyte
CHAR, jchar
SHORT, jshort
INT, jint
LONG, jlong
FLOAT, jfloat
DOUBLE, jdouble

:]m4svm_getset_field_end

m4svm_getset_static_begin[:

BOOLEAN, jboolean, z
BYTE, jbyte, b
CHAR, jchar, c
SHORT, jshort, s
INT, jint, i
LONG, jlong, j
FLOAT, jfloat, f
DOUBLE, jdouble, d

:]m4svm_getset_static_end

*/