1#include "shared.rsh"
2
3uint32_t x;
4uint32_t y;
5uint32_t z;
6
7rs_element elemNull;
8rs_element elemNonNull;
9rs_type typeNull;
10rs_type typeNonNull;
11rs_allocation allocNull;
12rs_allocation allocNonNull;
13rs_sampler samplerNull;
14rs_sampler samplerNonNull;
15rs_script scriptNull;
16rs_script scriptNonNull;
17
18volatile rs_data_type dt;
19volatile rs_data_kind dk;
20
21volatile rs_sampler_value rsv;
22
23volatile rs_time_t rst;
24volatile static rs_tm rstm;
25
26char *allocPtr;
27rs_allocation allocDst;
28
29volatile bool b;
30volatile char c;
31volatile char2 c2;
32volatile char3 c3;
33volatile char4 c4;
34volatile uchar uc;
35volatile uchar2 uc2;
36volatile uchar3 uc3;
37volatile uchar4 uc4;
38volatile short s;
39volatile short2 s2;
40volatile short3 s3;
41volatile short4 s4;
42volatile ushort us;
43volatile ushort2 us2;
44volatile ushort3 us3;
45volatile ushort4 us4;
46volatile int i;
47volatile int2 i2;
48volatile int3 i3;
49volatile int4 i4;
50volatile uint ui;
51volatile uint2 ui2;
52volatile uint3 ui3;
53volatile uint4 ui4;
54volatile long l;
55volatile long2 l2;
56volatile long3 l3;
57volatile long4 l4;
58volatile ulong ul;
59volatile ulong2 ul2;
60volatile ulong3 ul3;
61volatile ulong4 ul4;
62volatile long long ll;
63volatile unsigned long long ull;
64volatile float f;
65volatile float2 f2;
66volatile float3 f3;
67volatile float4 f4;
68volatile double d;
69volatile double2 d2;
70volatile double3 d3;
71volatile double4 d4;
72float fa[16];
73
74rs_allocation aChar;
75rs_allocation aChar2;
76rs_allocation aChar3;
77rs_allocation aChar4;
78rs_allocation aUChar;
79rs_allocation aUChar2;
80rs_allocation aUChar3;
81rs_allocation aUChar4;
82rs_allocation aShort;
83rs_allocation aShort2;
84rs_allocation aShort3;
85rs_allocation aShort4;
86rs_allocation aUShort;
87rs_allocation aUShort2;
88rs_allocation aUShort3;
89rs_allocation aUShort4;
90rs_allocation aInt;
91rs_allocation aInt2;
92rs_allocation aInt3;
93rs_allocation aInt4;
94rs_allocation aUInt;
95rs_allocation aUInt2;
96rs_allocation aUInt3;
97rs_allocation aUInt4;
98rs_allocation aLong;
99rs_allocation aLong2;
100rs_allocation aLong3;
101rs_allocation aLong4;
102rs_allocation aULong;
103rs_allocation aULong2;
104rs_allocation aULong3;
105rs_allocation aULong4;
106rs_allocation aFloat;
107rs_allocation aFloat2;
108rs_allocation aFloat3;
109rs_allocation aFloat4;
110rs_allocation aDouble;
111rs_allocation aDouble2;
112rs_allocation aDouble3;
113rs_allocation aDouble4;
114
115rs_matrix2x2 m2x2;
116rs_matrix3x3 m3x3;
117rs_matrix4x4 m4x4;
118
119// This function just checks that all of the called functions are
120// able to be linked. It is not intended to be executed!
121void check_api_presence() {
122    /********************************
123     * DO NOT EXECUTE THIS FUNCTION *
124     ********************************/
125    rsSendToClientBlocking(RS_MSG_TEST_FAILED);
126
127    // rs_allocation.rsh
128    c = rsGetElementAt_char(aChar, 0);
129    rsSetElementAt_char(aChar, c, 0);
130    c = rsGetElementAt_char(aChar, 0, 0);
131    rsSetElementAt_char(aChar, c, 0, 0);
132    c = rsGetElementAt_char(aChar, 0, 0, 0);
133    rsSetElementAt_char(aChar, c, 0, 0, 0);
134    c2 = rsGetElementAt_char2(aChar2, 0);
135    rsSetElementAt_char2(aChar2, c2, 0);
136    c2 = rsGetElementAt_char2(aChar2, 0, 0);
137    rsSetElementAt_char2(aChar2, c2, 0, 0);
138    c2 = rsGetElementAt_char2(aChar2, 0, 0, 0);
139    rsSetElementAt_char2(aChar2, c2, 0, 0, 0);
140    c3 = rsGetElementAt_char3(aChar3, 0);
141    rsSetElementAt_char3(aChar3, c3, 0);
142    c3 = rsGetElementAt_char3(aChar3, 0, 0);
143    rsSetElementAt_char3(aChar3, c3, 0, 0);
144    c3 = rsGetElementAt_char3(aChar3, 0, 0, 0);
145    rsSetElementAt_char3(aChar3, c3, 0, 0, 0);
146    c4 = rsGetElementAt_char4(aChar4, 0);
147    rsSetElementAt_char4(aChar4, c4, 0);
148    c4 = rsGetElementAt_char4(aChar4, 0, 0);
149    rsSetElementAt_char4(aChar4, c4, 0, 0);
150    c4 = rsGetElementAt_char4(aChar4, 0, 0, 0);
151    rsSetElementAt_char4(aChar4, c4, 0, 0, 0);
152
153    uc = rsGetElementAt_uchar(aUChar, 0);
154    rsSetElementAt_uchar(aUChar, uc, 0);
155    uc = rsGetElementAt_uchar(aUChar, 0, 0);
156    rsSetElementAt_uchar(aUChar, uc, 0, 0);
157    uc = rsGetElementAt_uchar(aUChar, 0, 0, 0);
158    rsSetElementAt_uchar(aUChar, uc, 0, 0, 0);
159    uc2 = rsGetElementAt_uchar2(aUChar2, 0);
160    rsSetElementAt_uchar2(aUChar2, uc2, 0);
161    uc2 = rsGetElementAt_uchar2(aUChar2, 0, 0);
162    rsSetElementAt_uchar2(aUChar2, uc2, 0, 0);
163    uc2 = rsGetElementAt_uchar2(aUChar2, 0, 0, 0);
164    rsSetElementAt_uchar2(aUChar2, uc2, 0, 0, 0);
165    uc3 = rsGetElementAt_uchar3(aUChar3, 0);
166    rsSetElementAt_uchar3(aUChar3, uc3, 0);
167    uc3 = rsGetElementAt_uchar3(aUChar3, 0, 0);
168    rsSetElementAt_uchar3(aUChar3, uc3, 0, 0);
169    uc3 = rsGetElementAt_uchar3(aUChar3, 0, 0, 0);
170    rsSetElementAt_uchar3(aUChar3, uc3, 0, 0, 0);
171    uc4 = rsGetElementAt_uchar4(aUChar4, 0);
172    rsSetElementAt_uchar4(aUChar4, uc4, 0);
173    uc4 = rsGetElementAt_uchar4(aUChar4, 0, 0);
174    rsSetElementAt_uchar4(aUChar4, uc4, 0, 0);
175    uc4 = rsGetElementAt_uchar4(aUChar4, 0, 0, 0);
176    rsSetElementAt_uchar4(aUChar4, uc4, 0, 0, 0);
177
178    s = rsGetElementAt_short(aShort, 0);
179    rsSetElementAt_short(aShort, s, 0);
180    s = rsGetElementAt_short(aShort, 0, 0);
181    rsSetElementAt_short(aShort, s, 0, 0);
182    s = rsGetElementAt_short(aShort, 0, 0, 0);
183    rsSetElementAt_short(aShort, s, 0, 0, 0);
184    s2 = rsGetElementAt_short2(aShort2, 0);
185    rsSetElementAt_short2(aShort2, s2, 0);
186    s2 = rsGetElementAt_short2(aShort2, 0, 0);
187    rsSetElementAt_short2(aShort2, s2, 0, 0);
188    s2 = rsGetElementAt_short2(aShort2, 0, 0, 0);
189    rsSetElementAt_short2(aShort2, s2, 0, 0, 0);
190    s3 = rsGetElementAt_short3(aShort3, 0);
191    rsSetElementAt_short3(aShort3, s3, 0);
192    s3 = rsGetElementAt_short3(aShort3, 0, 0);
193    rsSetElementAt_short3(aShort3, s3, 0, 0);
194    s3 = rsGetElementAt_short3(aShort3, 0, 0, 0);
195    rsSetElementAt_short3(aShort3, s3, 0, 0, 0);
196    s4 = rsGetElementAt_short4(aShort4, 0);
197    rsSetElementAt_short4(aShort4, s4, 0);
198    s4 = rsGetElementAt_short4(aShort4, 0, 0);
199    rsSetElementAt_short4(aShort4, s4, 0, 0);
200    s4 = rsGetElementAt_short4(aShort4, 0, 0, 0);
201    rsSetElementAt_short4(aShort4, s4, 0, 0, 0);
202
203    us = rsGetElementAt_ushort(aUShort, 0);
204    rsSetElementAt_ushort(aUShort, us, 0);
205    us = rsGetElementAt_ushort(aUShort, 0, 0);
206    rsSetElementAt_ushort(aUShort, us, 0, 0);
207    us = rsGetElementAt_ushort(aUShort, 0, 0, 0);
208    rsSetElementAt_ushort(aUShort, us, 0, 0, 0);
209    us2 = rsGetElementAt_ushort2(aUShort2, 0);
210    rsSetElementAt_ushort2(aUShort2, us2, 0);
211    us2 = rsGetElementAt_ushort2(aUShort2, 0, 0);
212    rsSetElementAt_ushort2(aUShort2, us2, 0, 0);
213    us2 = rsGetElementAt_ushort2(aUShort2, 0, 0, 0);
214    rsSetElementAt_ushort2(aUShort2, us2, 0, 0, 0);
215    us3 = rsGetElementAt_ushort3(aUShort3, 0);
216    rsSetElementAt_ushort3(aUShort3, us3, 0);
217    us3 = rsGetElementAt_ushort3(aUShort3, 0, 0);
218    rsSetElementAt_ushort3(aUShort3, us3, 0, 0);
219    us3 = rsGetElementAt_ushort3(aUShort3, 0, 0, 0);
220    rsSetElementAt_ushort3(aUShort3, us3, 0, 0, 0);
221    us4 = rsGetElementAt_ushort4(aUShort4, 0);
222    rsSetElementAt_ushort4(aUShort4, us4, 0);
223    us4 = rsGetElementAt_ushort4(aUShort4, 0, 0);
224    rsSetElementAt_ushort4(aUShort4, us4, 0, 0);
225    us4 = rsGetElementAt_ushort4(aUShort4, 0, 0, 0);
226    rsSetElementAt_ushort4(aUShort4, us4, 0, 0, 0);
227
228    i = rsGetElementAt_int(aInt, 0);
229    rsSetElementAt_int(aInt, i, 0);
230    i = rsGetElementAt_int(aInt, 0, 0);
231    rsSetElementAt_int(aInt, i, 0, 0);
232    i = rsGetElementAt_int(aInt, 0, 0, 0);
233    rsSetElementAt_int(aInt, i, 0, 0, 0);
234    i2 = rsGetElementAt_int2(aInt2, 0);
235    rsSetElementAt_int2(aInt2, i2, 0);
236    i2 = rsGetElementAt_int2(aInt2, 0, 0);
237    rsSetElementAt_int2(aInt2, i2, 0, 0);
238    i2 = rsGetElementAt_int2(aInt2, 0, 0, 0);
239    rsSetElementAt_int2(aInt2, i2, 0, 0, 0);
240    i3 = rsGetElementAt_int3(aInt3, 0);
241    rsSetElementAt_int3(aInt3, i3, 0);
242    i3 = rsGetElementAt_int3(aInt3, 0, 0);
243    rsSetElementAt_int3(aInt3, i3, 0, 0);
244    i3 = rsGetElementAt_int3(aInt3, 0, 0, 0);
245    rsSetElementAt_int3(aInt3, i3, 0, 0, 0);
246    i4 = rsGetElementAt_int4(aInt4, 0);
247    rsSetElementAt_int4(aInt4, i4, 0);
248    i4 = rsGetElementAt_int4(aInt4, 0, 0);
249    rsSetElementAt_int4(aInt4, i4, 0, 0);
250    i4 = rsGetElementAt_int4(aInt4, 0, 0, 0);
251    rsSetElementAt_int4(aInt4, i4, 0, 0, 0);
252
253    ui = rsGetElementAt_uint(aUInt, 0);
254    rsSetElementAt_uint(aUInt, ui, 0);
255    ui = rsGetElementAt_uint(aUInt, 0, 0);
256    rsSetElementAt_uint(aUInt, ui, 0, 0);
257    ui = rsGetElementAt_uint(aUInt, 0, 0, 0);
258    rsSetElementAt_uint(aUInt, ui, 0, 0, 0);
259    ui2 = rsGetElementAt_uint2(aUInt2, 0);
260    rsSetElementAt_uint2(aUInt2, ui2, 0);
261    ui2 = rsGetElementAt_uint2(aUInt2, 0, 0);
262    rsSetElementAt_uint2(aUInt2, ui2, 0, 0);
263    ui2 = rsGetElementAt_uint2(aUInt2, 0, 0, 0);
264    rsSetElementAt_uint2(aUInt2, ui2, 0, 0, 0);
265    ui3 = rsGetElementAt_uint3(aUInt3, 0);
266    rsSetElementAt_uint3(aUInt3, ui3, 0);
267    ui3 = rsGetElementAt_uint3(aUInt3, 0, 0);
268    rsSetElementAt_uint3(aUInt3, ui3, 0, 0);
269    ui3 = rsGetElementAt_uint3(aUInt3, 0, 0, 0);
270    rsSetElementAt_uint3(aUInt3, ui3, 0, 0, 0);
271    ui4 = rsGetElementAt_uint4(aUInt4, 0);
272    rsSetElementAt_uint4(aUInt4, ui4, 0);
273    ui4 = rsGetElementAt_uint4(aUInt4, 0, 0);
274    rsSetElementAt_uint4(aUInt4, ui4, 0, 0);
275    ui4 = rsGetElementAt_uint4(aUInt4, 0, 0, 0);
276    rsSetElementAt_uint4(aUInt4, ui4, 0, 0, 0);
277
278    l = rsGetElementAt_long(aLong, 0);
279    rsSetElementAt_long(aLong, l, 0);
280    l = rsGetElementAt_long(aLong, 0, 0);
281    rsSetElementAt_long(aLong, l, 0, 0);
282    l = rsGetElementAt_long(aLong, 0, 0, 0);
283    rsSetElementAt_long(aLong, l, 0, 0, 0);
284    l2 = rsGetElementAt_long2(aLong2, 0);
285    rsSetElementAt_long2(aLong2, l2, 0);
286    l2 = rsGetElementAt_long2(aLong2, 0, 0);
287    rsSetElementAt_long2(aLong2, l2, 0, 0);
288    l2 = rsGetElementAt_long2(aLong2, 0, 0, 0);
289    rsSetElementAt_long2(aLong2, l2, 0, 0, 0);
290    l3 = rsGetElementAt_long3(aLong3, 0);
291    rsSetElementAt_long3(aLong3, l3, 0);
292    l3 = rsGetElementAt_long3(aLong3, 0, 0);
293    rsSetElementAt_long3(aLong3, l3, 0, 0);
294    l3 = rsGetElementAt_long3(aLong3, 0, 0, 0);
295    rsSetElementAt_long3(aLong3, l3, 0, 0, 0);
296    l4 = rsGetElementAt_long4(aLong4, 0);
297    rsSetElementAt_long4(aLong4, l4, 0);
298    l4 = rsGetElementAt_long4(aLong4, 0, 0);
299    rsSetElementAt_long4(aLong4, l4, 0, 0);
300    l4 = rsGetElementAt_long4(aLong4, 0, 0, 0);
301    rsSetElementAt_long4(aLong4, l4, 0, 0, 0);
302
303    ul = rsGetElementAt_ulong(aULong, 0);
304    rsSetElementAt_ulong(aULong, ul, 0);
305    ul = rsGetElementAt_ulong(aULong, 0, 0);
306    rsSetElementAt_ulong(aULong, ul, 0, 0);
307    ul = rsGetElementAt_ulong(aULong, 0, 0, 0);
308    rsSetElementAt_ulong(aULong, ul, 0, 0, 0);
309    ul2 = rsGetElementAt_ulong2(aULong2, 0);
310    rsSetElementAt_ulong2(aULong2, ul2, 0);
311    ul2 = rsGetElementAt_ulong2(aULong2, 0, 0);
312    rsSetElementAt_ulong2(aULong2, ul2, 0, 0);
313    ul2 = rsGetElementAt_ulong2(aULong2, 0, 0, 0);
314    rsSetElementAt_ulong2(aULong2, ul2, 0, 0, 0);
315    ul3 = rsGetElementAt_ulong3(aULong3, 0);
316    rsSetElementAt_ulong3(aULong3, ul3, 0);
317    ul3 = rsGetElementAt_ulong3(aULong3, 0, 0);
318    rsSetElementAt_ulong3(aULong3, ul3, 0, 0);
319    ul3 = rsGetElementAt_ulong3(aULong3, 0, 0, 0);
320    rsSetElementAt_ulong3(aULong3, ul3, 0, 0, 0);
321    ul4 = rsGetElementAt_ulong4(aULong4, 0);
322    rsSetElementAt_ulong4(aULong4, ul4, 0);
323    ul4 = rsGetElementAt_ulong4(aULong4, 0, 0);
324    rsSetElementAt_ulong4(aULong4, ul4, 0, 0);
325    ul4 = rsGetElementAt_ulong4(aULong4, 0, 0, 0);
326    rsSetElementAt_ulong4(aULong4, ul4, 0, 0, 0);
327
328    f = rsGetElementAt_float(aFloat, 0);
329    rsSetElementAt_float(aFloat, f, 0);
330    f = rsGetElementAt_float(aFloat, 0, 0);
331    rsSetElementAt_float(aFloat, f, 0, 0);
332    f = rsGetElementAt_float(aFloat, 0, 0, 0);
333    rsSetElementAt_float(aFloat, f, 0, 0, 0);
334    f2 = rsGetElementAt_float2(aFloat2, 0);
335    rsSetElementAt_float2(aFloat2, f2, 0);
336    f2 = rsGetElementAt_float2(aFloat2, 0, 0);
337    rsSetElementAt_float2(aFloat2, f2, 0, 0);
338    f2 = rsGetElementAt_float2(aFloat2, 0, 0, 0);
339    rsSetElementAt_float2(aFloat2, f2, 0, 0, 0);
340    f3 = rsGetElementAt_float3(aFloat3, 0);
341    rsSetElementAt_float3(aFloat3, f3, 0);
342    f3 = rsGetElementAt_float3(aFloat3, 0, 0);
343    rsSetElementAt_float3(aFloat3, f3, 0, 0);
344    f3 = rsGetElementAt_float3(aFloat3, 0, 0, 0);
345    rsSetElementAt_float3(aFloat3, f3, 0, 0, 0);
346    f4 = rsGetElementAt_float4(aFloat4, 0);
347    rsSetElementAt_float4(aFloat4, f4, 0);
348    f4 = rsGetElementAt_float4(aFloat4, 0, 0);
349    rsSetElementAt_float4(aFloat4, f4, 0, 0);
350    f4 = rsGetElementAt_float4(aFloat4, 0, 0, 0);
351    rsSetElementAt_float4(aFloat4, f4, 0, 0, 0);
352
353    d = rsGetElementAt_double(aDouble, 0);
354    rsSetElementAt_double(aDouble, d, 0);
355    d = rsGetElementAt_double(aDouble, 0, 0);
356    rsSetElementAt_double(aDouble, d, 0, 0);
357    d = rsGetElementAt_double(aDouble, 0, 0, 0);
358    rsSetElementAt_double(aDouble, d, 0, 0, 0);
359    d2 = rsGetElementAt_double2(aDouble2, 0);
360    rsSetElementAt_double2(aDouble2, d2, 0);
361    d2 = rsGetElementAt_double2(aDouble2, 0, 0);
362    rsSetElementAt_double2(aDouble2, d2, 0, 0);
363    d2 = rsGetElementAt_double2(aDouble2, 0, 0, 0);
364    rsSetElementAt_double2(aDouble2, d2, 0, 0, 0);
365    d3 = rsGetElementAt_double3(aDouble3, 0);
366    rsSetElementAt_double3(aDouble3, d3, 0);
367    d3 = rsGetElementAt_double3(aDouble3, 0, 0);
368    rsSetElementAt_double3(aDouble3, d3, 0, 0);
369    d3 = rsGetElementAt_double3(aDouble3, 0, 0, 0);
370    rsSetElementAt_double3(aDouble3, d3, 0, 0, 0);
371    d4 = rsGetElementAt_double4(aDouble4, 0);
372    rsSetElementAt_double4(aDouble4, d4, 0);
373    d4 = rsGetElementAt_double4(aDouble4, 0, 0);
374    rsSetElementAt_double4(aDouble4, d4, 0, 0);
375    d4 = rsGetElementAt_double4(aDouble4, 0, 0, 0);
376    rsSetElementAt_double4(aDouble4, d4, 0, 0, 0);
377
378    uc3.x = rsGetElementAtYuv_uchar_Y(aUChar4, 0, 0);
379    uc3.y = rsGetElementAtYuv_uchar_U(aUChar4, 0, 0);
380    uc3.z = rsGetElementAtYuv_uchar_V(aUChar4, 0, 0);
381
382    c3.x = *(char*)rsGetElementAt(aChar3, 0);
383    c3.y = *(char*)rsGetElementAt(aChar3, 0, 0);
384    c3.z = *(char*)rsGetElementAt(aChar3, 0, 0, 0);
385
386    rsAllocationIoSend(aInt);
387    rsAllocationIoReceive(aInt);
388
389    elemNonNull = rsAllocationGetElement(aInt);
390
391    rsAllocationCopy1DRange(allocDst, 0, 0, 0, allocDst, 0, 0);
392    rsAllocationCopy2DRange(allocDst, 0, 0, 0, 0, 0, 0, allocDst, 0, 0, 0, 0);
393
394    // rsSample routines
395    f4 += rsSample(allocDst, samplerNonNull, f);
396    f4 += rsSample(allocDst, samplerNonNull, f, f);
397    f4 += rsSample(allocDst, samplerNonNull, f2);
398    f4 += rsSample(allocDst, samplerNonNull, f2, f);
399
400    // rs_atomic.rsh
401    rsAtomicInc(&i);
402    rsAtomicDec(&i);
403    rsAtomicAdd(&i, 1);
404    rsAtomicSub(&i, 2);
405    rsAtomicAnd(&i, 3);
406    rsAtomicOr(&i, 4);
407    rsAtomicXor(&i, 5);
408    rsAtomicMin(&i, 6);
409    rsAtomicMin(&ui, 6);
410    rsAtomicMax(&i, 7);
411    rsAtomicMax(&ui, 7);
412    rsAtomicCas(&i, 8, 9);
413    rsAtomicCas(&ui, 8, 9);
414
415    // rs_cl.rsh
416    c2 = convert_char2(c2);
417    c2 = convert_char2(uc2);
418    c2 = convert_char2(s2);
419    c2 = convert_char2(us2);
420    c2 = convert_char2(i2);
421    c2 = convert_char2(ui2);
422    c2 = convert_char2(f2);
423    c3 = convert_char3(c3);
424    c3 = convert_char3(uc3);
425    c3 = convert_char3(s3);
426    c3 = convert_char3(us3);
427    c3 = convert_char3(i3);
428    c3 = convert_char3(ui3);
429    c3 = convert_char3(f3);
430    c4 = convert_char4(c4);
431    c4 = convert_char4(uc4);
432    c4 = convert_char4(s4);
433    c4 = convert_char4(us4);
434    c4 = convert_char4(i4);
435    c4 = convert_char4(ui4);
436    c4 = convert_char4(f4);
437
438    uc2 = convert_uchar2(c2);
439    uc2 = convert_uchar2(uc2);
440    uc2 = convert_uchar2(s2);
441    uc2 = convert_uchar2(us2);
442    uc2 = convert_uchar2(i2);
443    uc2 = convert_uchar2(ui2);
444    uc2 = convert_uchar2(f2);
445    uc3 = convert_uchar3(c3);
446    uc3 = convert_uchar3(uc3);
447    uc3 = convert_uchar3(s3);
448    uc3 = convert_uchar3(us3);
449    uc3 = convert_uchar3(i3);
450    uc3 = convert_uchar3(ui3);
451    uc3 = convert_uchar3(f3);
452    uc4 = convert_uchar4(c4);
453    uc4 = convert_uchar4(uc4);
454    uc4 = convert_uchar4(s4);
455    uc4 = convert_uchar4(us4);
456    uc4 = convert_uchar4(i4);
457    uc4 = convert_uchar4(ui4);
458    uc4 = convert_uchar4(f4);
459
460    s2 = convert_short2(c2);
461    s2 = convert_short2(uc2);
462    s2 = convert_short2(s2);
463    s2 = convert_short2(us2);
464    s2 = convert_short2(i2);
465    s2 = convert_short2(ui2);
466    s2 = convert_short2(f2);
467    s3 = convert_short3(c3);
468    s3 = convert_short3(uc3);
469    s3 = convert_short3(s3);
470    s3 = convert_short3(us3);
471    s3 = convert_short3(i3);
472    s3 = convert_short3(ui3);
473    s3 = convert_short3(f3);
474    s4 = convert_short4(c4);
475    s4 = convert_short4(uc4);
476    s4 = convert_short4(s4);
477    s4 = convert_short4(us4);
478    s4 = convert_short4(i4);
479    s4 = convert_short4(ui4);
480    s4 = convert_short4(f4);
481
482    us2 = convert_ushort2(c2);
483    us2 = convert_ushort2(uc2);
484    us2 = convert_ushort2(s2);
485    us2 = convert_ushort2(us2);
486    us2 = convert_ushort2(i2);
487    us2 = convert_ushort2(ui2);
488    us2 = convert_ushort2(f2);
489    us3 = convert_ushort3(c3);
490    us3 = convert_ushort3(uc3);
491    us3 = convert_ushort3(s3);
492    us3 = convert_ushort3(us3);
493    us3 = convert_ushort3(i3);
494    us3 = convert_ushort3(ui3);
495    us3 = convert_ushort3(f3);
496    us4 = convert_ushort4(c4);
497    us4 = convert_ushort4(uc4);
498    us4 = convert_ushort4(s4);
499    us4 = convert_ushort4(us4);
500    us4 = convert_ushort4(i4);
501    us4 = convert_ushort4(ui4);
502    us4 = convert_ushort4(f4);
503
504    i2 = convert_int2(c2);
505    i2 = convert_int2(uc2);
506    i2 = convert_int2(s2);
507    i2 = convert_int2(us2);
508    i2 = convert_int2(i2);
509    i2 = convert_int2(ui2);
510    i2 = convert_int2(f2);
511    i3 = convert_int3(c3);
512    i3 = convert_int3(uc3);
513    i3 = convert_int3(s3);
514    i3 = convert_int3(us3);
515    i3 = convert_int3(i3);
516    i3 = convert_int3(ui3);
517    i3 = convert_int3(f3);
518    i4 = convert_int4(c4);
519    i4 = convert_int4(uc4);
520    i4 = convert_int4(s4);
521    i4 = convert_int4(us4);
522    i4 = convert_int4(i4);
523    i4 = convert_int4(ui4);
524    i4 = convert_int4(f4);
525
526    ui2 = convert_uint2(c2);
527    ui2 = convert_uint2(uc2);
528    ui2 = convert_uint2(s2);
529    ui2 = convert_uint2(us2);
530    ui2 = convert_uint2(i2);
531    ui2 = convert_uint2(ui2);
532    ui2 = convert_uint2(f2);
533    ui3 = convert_uint3(c3);
534    ui3 = convert_uint3(uc3);
535    ui3 = convert_uint3(s3);
536    ui3 = convert_uint3(us3);
537    ui3 = convert_uint3(i3);
538    ui3 = convert_uint3(ui3);
539    ui3 = convert_uint3(f3);
540    ui4 = convert_uint4(c4);
541    ui4 = convert_uint4(uc4);
542    ui4 = convert_uint4(s4);
543    ui4 = convert_uint4(us4);
544    ui4 = convert_uint4(i4);
545    ui4 = convert_uint4(ui4);
546    ui4 = convert_uint4(f4);
547
548    f2 = convert_float2(c2);
549    f2 = convert_float2(uc2);
550    f2 = convert_float2(s2);
551    f2 = convert_float2(us2);
552    f2 = convert_float2(i2);
553    f2 = convert_float2(ui2);
554    f2 = convert_float2(f2);
555    f3 = convert_float3(c3);
556    f3 = convert_float3(uc3);
557    f3 = convert_float3(s3);
558    f3 = convert_float3(us3);
559    f3 = convert_float3(i3);
560    f3 = convert_float3(ui3);
561    f3 = convert_float3(f3);
562    f4 = convert_float4(c4);
563    f4 = convert_float4(uc4);
564    f4 = convert_float4(s4);
565    f4 = convert_float4(us4);
566    f4 = convert_float4(i4);
567    f4 = convert_float4(ui4);
568    f4 = convert_float4(f4);
569
570    // FIXME: No support for long/double (either from/to).
571
572    // math
573    f = acos(f);
574    f2 = acos(f2);
575    f3 = acos(f3);
576    f4 = acos(f4);
577    f = acosh(f);
578    f2 = acosh(f2);
579    f3 = acosh(f3);
580    f4 = acosh(f4);
581    f = acospi(f);
582    f2 = acospi(f2);
583    f3 = acospi(f3);
584    f4 = acospi(f4);
585
586    f = asin(f);
587    f2 = asin(f2);
588    f3 = asin(f3);
589    f4 = asin(f4);
590    f = asinh(f);
591    f2 = asinh(f2);
592    f3 = asinh(f3);
593    f4 = asinh(f4);
594    f = asinpi(f);
595    f2 = asinpi(f2);
596    f3 = asinpi(f3);
597    f4 = asinpi(f4);
598
599    f = atan(f);
600    f2 = atan(f2);
601    f3 = atan(f3);
602    f4 = atan(f4);
603    f = atanh(f);
604    f2 = atanh(f2);
605    f3 = atanh(f3);
606    f4 = atanh(f4);
607    f = atanpi(f);
608    f2 = atanpi(f2);
609    f3 = atanpi(f3);
610    f4 = atanpi(f4);
611
612    f = atan2(f, f);
613    f2 = atan2(f2, f2);
614    f3 = atan2(f3, f3);
615    f4 = atan2(f4, f4);
616    f = atan2pi(f, f);
617    f2 = atan2pi(f2, f2);
618    f3 = atan2pi(f3, f3);
619    f4 = atan2(f4, f4);
620
621    f = cbrt(f);
622    f2 = cbrt(f2);
623    f3 = cbrt(f3);
624    f4 = cbrt(f4);
625
626    f = ceil(f);
627    f2 = ceil(f2);
628    f3 = ceil(f3);
629    f4 = ceil(f4);
630
631    f = copysign(f, f);
632    f2 = copysign(f2, f2);
633    f3 = copysign(f3, f3);
634    f4 = copysign(f4, f4);
635
636    f = cos(f);
637    f2 = cos(f2);
638    f3 = cos(f3);
639    f4 = cos(f4);
640    f = cosh(f);
641    f2 = cosh(f2);
642    f3 = cosh(f3);
643    f4 = cosh(f4);
644    f = cospi(f);
645    f2 = cospi(f2);
646    f3 = cospi(f3);
647    f4 = cospi(f4);
648
649    f = erfc(f);
650    f2 = erfc(f2);
651    f3 = erfc(f3);
652    f4 = erfc(f4);
653    f = erf(f);
654    f2 = erf(f2);
655    f3 = erf(f3);
656    f4 = erf(f4);
657
658    f = exp(f);
659    f2 = exp(f2);
660    f3 = exp(f3);
661    f4 = exp(f4);
662    f = exp2(f);
663    f2 = exp2(f2);
664    f3 = exp2(f3);
665    f4 = exp2(f4);
666
667    f = pow(f, f);
668    f2 = pow(f2, f2);
669    f3 = pow(f3, f3);
670    f4 = pow(f4, f4);
671
672    f = exp10(f);
673    f2 = exp10(f2);
674    f3 = exp10(f3);
675    f4 = exp10(f4);
676
677    f = expm1(f);
678    f2 = expm1(f2);
679    f3 = expm1(f3);
680    f4 = expm1(f4);
681
682    f = fabs(f);
683    f2 = fabs(f2);
684    f3 = fabs(f3);
685    f4 = fabs(f4);
686
687    f = fabs(f);
688    f2 = fabs(f2);
689    f3 = fabs(f3);
690    f4 = fabs(f4);
691
692    f = fdim(f, f);
693    f2 = fdim(f2, f2);
694    f3 = fdim(f3, f3);
695    f4 = fdim(f4, f4);
696
697    f = floor(f);
698    f2 = floor(f2);
699    f3 = floor(f3);
700    f4 = floor(f4);
701
702    f = fma(f, f, f);
703    f2 = fma(f2, f2, f2);
704    f3 = fma(f3, f3, f3);
705    f4 = fma(f4, f4, f4);
706
707    f = fmax(f, f);
708    f2 = fmax(f2, f2);
709    f3 = fmax(f3, f3);
710    f4 = fmax(f4, f4);
711
712    f = fmin(f, f);
713    f2 = fmin(f2, f2);
714    f3 = fmin(f3, f3);
715    f4 = fmin(f4, f4);
716
717    f = fmod(f, f);
718    f2 = fmod(f2, f2);
719    f3 = fmod(f3, f3);
720    f4 = fmod(f4, f4);
721
722    f = fract(f, (float *)&f);
723    f2 = fract(f2, (float2 *)&f2);
724    f3 = fract(f3, (float3 *)&f3);
725    f4 = fract(f4, (float4 *)&f4);
726    f = fract(f);
727    f2 = fract(f2);
728    f3 = fract(f3);
729    f4 = fract(f4);
730
731    f = frexp(f, (int *)&i);
732    f2 = frexp(f2, (int2 *)&i2);
733    f3 = frexp(f3, (int3 *)&i3);
734    f4 = frexp(f4, (int4 *)&i4);
735
736    f = hypot(f, f);
737    f2 = hypot(f2, f2);
738    f3 = hypot(f3, f3);
739    f4 = hypot(f4, f4);
740
741    i = ilogb(f);
742    i2 = ilogb(f2);
743    i3 = ilogb(f3);
744    i4 = ilogb(f4);
745
746    f = ldexp(f, i);
747    f2 = ldexp(f2, i2);
748    f3 = ldexp(f3, i3);
749    f4 = ldexp(f4, i4);
750    f2 = ldexp(f2, i);
751    f3 = ldexp(f3, i);
752    f4 = ldexp(f4, i);
753
754    f = lgamma(f);
755    f2 = lgamma(f2);
756    f3 = lgamma(f3);
757    f4 = lgamma(f4);
758    f = lgamma(f, (int *)&i);
759    f2 = lgamma(f2, (int2 *)&i2);
760    f3 = lgamma(f3, (int3 *)&i3);
761    f4 = lgamma(f4, (int4 *)&i4);
762
763    f = log(f);
764    f2 = log(f2);
765    f3 = log(f3);
766    f4 = log(f4);
767
768    f = log10(f);
769    f2 = log10(f2);
770    f3 = log10(f3);
771    f4 = log10(f4);
772
773    f = log2(f);
774    f2 = log2(f2);
775    f3 = log2(f3);
776    f4 = log2(f4);
777
778    f = log1p(f);
779    f2 = log1p(f2);
780    f3 = log1p(f3);
781    f4 = log1p(f4);
782
783    f = logb(f);
784    f2 = logb(f2);
785    f3 = logb(f3);
786    f4 = logb(f4);
787
788    f = mad(f, f, f);
789    f2 = mad(f2, f2, f2);
790    f3 = mad(f3, f3, f3);
791    f4 = mad(f4, f4, f4);
792
793    f = modf(f, (float *)&f);
794    f2 = modf(f2, (float2 *)&f2);
795    f3 = modf(f3, (float3 *)&f3);
796    f4 = modf(f4, (float4 *)&f4);
797
798    f = nan(ui);
799
800    f = nextafter(f, f);
801    f2 = nextafter(f2, f2);
802    f3 = nextafter(f3, f3);
803    f4 = nextafter(f4, f4);
804
805    f = pown(f, i);
806    f2 = pown(f2, i2);
807    f3 = pown(f3, i3);
808    f4 = pown(f4, i4);
809
810    f = powr(f, f);
811    f2 = powr(f2, f2);
812    f3 = powr(f3, f3);
813    f4 = powr(f4, f4);
814
815    f = remainder(f, f);
816    f2 = remainder(f2, f2);
817    f3 = remainder(f3, f3);
818    f4 = remainder(f4, f4);
819
820    f = remquo(f, f, (int *)&i);
821    f2 = remquo(f2, f2, (int2 *)&i2);
822    f3 = remquo(f3, f3, (int3 *)&i3);
823    f4 = remquo(f4, f4, (int4 *)&i4);
824
825    f = rint(f);
826    f2 = rint(f2);
827    f3 = rint(f3);
828    f4 = rint(f4);
829
830    f = rootn(f, i);
831    f2 = rootn(f2, i2);
832    f3 = rootn(f3, i3);
833    f4 = rootn(f4, i4);
834
835    f = round(f);
836    f2 = round(f2);
837    f3 = round(f3);
838    f4 = round(f4);
839
840    f = rsqrt(f);
841    f2 = rsqrt(f2);
842    f3 = rsqrt(f3);
843    f4 = rsqrt(f4);
844
845    f = sin(f);
846    f2 = sin(f2);
847    f3 = sin(f3);
848    f4 = sin(f4);
849    f = sinh(f);
850    f2 = sinh(f2);
851    f3 = sinh(f3);
852    f4 = sinh(f4);
853    f = sinpi(f);
854    f2 = sinpi(f2);
855    f3 = sinpi(f3);
856    f4 = sinpi(f4);
857
858    f = sincos(f, (float *)&f);
859    f2 = sincos(f2, (float2 *)&f2);
860    f3 = sincos(f3, (float3 *)&f3);
861    f4 = sincos(f4, (float4 *)&f4);
862
863    f = tan(f);
864    f2 = tan(f2);
865    f3 = tan(f3);
866    f4 = tan(f4);
867    f = tanh(f);
868    f2 = tanh(f2);
869    f3 = tanh(f3);
870    f4 = tanh(f4);
871    f = tanpi(f);
872    f2 = tanpi(f2);
873    f3 = tanpi(f3);
874    f4 = tanpi(f4);
875
876    f = tgamma(f);
877    f2 = tgamma(f2);
878    f3 = tgamma(f3);
879    f4 = tgamma(f4);
880
881    f = trunc(f);
882    f2 = trunc(f2);
883    f3 = trunc(f3);
884    f4 = trunc(f4);
885
886    uc = abs(c);
887    uc2 = abs(c2);
888    uc3 = abs(c3);
889    uc4 = abs(c4);
890    us = abs(s);
891    us2 = abs(s2);
892    us3 = abs(s3);
893    us4 = abs(s4);
894    ui = abs(i);
895    ui2 = abs(i2);
896    ui3 = abs(i3);
897    ui4 = abs(i4);
898
899    c = clz(c);
900    c2 = clz(c2);
901    c3 = clz(c3);
902    c4 = clz(c4);
903    uc = clz(uc);
904    uc2 = clz(uc2);
905    uc3 = clz(uc3);
906    uc4 = clz(uc4);
907    s = clz(s);
908    s2 = clz(s2);
909    s3 = clz(s3);
910    s4 = clz(s4);
911    us = clz(us);
912    us2 = clz(us2);
913    us3 = clz(us3);
914    us4 = clz(us4);
915    i = clz(i);
916    i2 = clz(i2);
917    i3 = clz(i3);
918    i4 = clz(i4);
919    ui = clz(ui);
920    ui2 = clz(ui2);
921    ui3 = clz(ui3);
922    ui4 = clz(ui4);
923
924    c = min(c, c);
925    c2 = min(c2, c2);
926    c3 = min(c3, c3);
927    c4 = min(c4, c4);
928    uc = min(uc, uc);
929    uc2 = min(uc2, uc2);
930    uc3 = min(uc3, uc3);
931    uc4 = min(uc4, uc4);
932    s = min(s, s);
933    s2 = min(s2, s2);
934    s3 = min(s3, s3);
935    s4 = min(s4, s4);
936    us = min(us, us);
937    us2 = min(us2, us2);
938    us3 = min(us3, us3);
939    us4 = min(us4, us4);
940    i = min(i, i);
941    i2 = min(i2, i2);
942    i3 = min(i3, i3);
943    i4 = min(i4, i4);
944    ui = min(ui, ui);
945    ui2 = min(ui2, ui2);
946    ui3 = min(ui3, ui3);
947    ui4 = min(ui4, ui4);
948    f = min(f, f);
949    f2 = min(f2, f2);
950    f3 = min(f3, f3);
951    f4 = min(f4, f4);
952    f2 = min(f2, f);
953    f3 = min(f3, f);
954    f4 = min(f4, f);
955
956    c = max(c, c);
957    c2 = max(c2, c2);
958    c3 = max(c3, c3);
959    c4 = max(c4, c4);
960    uc = max(uc, uc);
961    uc2 = max(uc2, uc2);
962    uc3 = max(uc3, uc3);
963    uc4 = max(uc4, uc4);
964    s = max(s, s);
965    s2 = max(s2, s2);
966    s3 = max(s3, s3);
967    s4 = max(s4, s4);
968    us = max(us, us);
969    us2 = max(us2, us2);
970    us3 = max(us3, us3);
971    us4 = max(us4, us4);
972    i = max(i, i);
973    i2 = max(i2, i2);
974    i3 = max(i3, i3);
975    i4 = max(i4, i4);
976    ui = max(ui, ui);
977    ui2 = max(ui2, ui2);
978    ui3 = max(ui3, ui3);
979    ui4 = max(ui4, ui4);
980    f = max(f, f);
981    f2 = max(f2, f2);
982    f3 = max(f3, f3);
983    f4 = max(f4, f4);
984    f2 = max(f2, f);
985    f3 = max(f3, f);
986    f4 = max(f4, f);
987
988    f = clamp(f, f, f);
989    f2 = clamp(f2, f2, f2);
990    f3 = clamp(f3, f3, f3);
991    f4 = clamp(f4, f4, f4);
992    f2 = clamp(f2, f, f);
993    f3 = clamp(f3, f, f);
994    f4 = clamp(f4, f, f);
995    // FIXME: other clamps only in 19+
996
997    f = degrees(f);
998    f2 = degrees(f2);
999    f3 = degrees(f3);
1000    f4 = degrees(f4);
1001
1002    f = mix(f, f, f);
1003    f2 = mix(f2, f2, f2);
1004    f3 = mix(f3, f3, f3);
1005    f4 = mix(f4, f4, f4);
1006    f2 = mix(f2, f2, f);
1007    f3 = mix(f3, f3, f);
1008    f4 = mix(f4, f4, f);
1009
1010    f = radians(f);
1011    f2 = radians(f2);
1012    f3 = radians(f3);
1013    f4 = radians(f4);
1014
1015    f = step(f, f);
1016    f2 = step(f2, f2);
1017    f3 = step(f3, f3);
1018    f4 = step(f4, f4);
1019    f2 = step(f2, f);
1020    f3 = step(f3, f);
1021    f4 = step(f4, f);
1022
1023    f = sign(f);
1024    f2 = sign(f2);
1025    f3 = sign(f3);
1026    f4 = sign(f4);
1027
1028    f3 = cross(f3, f3);
1029    f4 = cross(f4, f4);
1030
1031    f = dot(f, f);
1032    f = dot(f2, f2);
1033    f = dot(f3, f3);
1034    f = dot(f4, f4);
1035
1036    f = length(f);
1037    f = length(f2);
1038    f = length(f3);
1039    f = length(f4);
1040
1041    f = distance(f, f);
1042    f = distance(f2, f2);
1043    f = distance(f3, f3);
1044    f = distance(f4, f4);
1045
1046    f = normalize(f);
1047    f2 = normalize(f2);
1048    f3 = normalize(f3);
1049    f4 = normalize(f4);
1050
1051    f = half_recip(f);
1052    f2 = half_recip(f2);
1053    f3 = half_recip(f3);
1054    f4 = half_recip(f4);
1055
1056    f = half_sqrt(f);
1057    f2 = half_sqrt(f2);
1058    f3 = half_sqrt(f3);
1059    f4 = half_sqrt(f4);
1060
1061    f = half_rsqrt(f);
1062    f2 = half_rsqrt(f2);
1063    f3 = half_rsqrt(f3);
1064    f4 = half_rsqrt(f4);
1065
1066    f = fast_length(f);
1067    f = fast_length(f2);
1068    f = fast_length(f3);
1069    f = fast_length(f4);
1070
1071    f = fast_distance(f, f);
1072    f = fast_distance(f2, f2);
1073    f = fast_distance(f3, f3);
1074    f = fast_distance(f4, f4);
1075
1076    f = fast_normalize(f);
1077    f2 = fast_normalize(f2);
1078    f3 = fast_normalize(f3);
1079    f4 = fast_normalize(f4);
1080
1081    f = native_exp2(f);
1082    f2 = native_exp2(f2);
1083    f3 = native_exp2(f3);
1084    f4 = native_exp2(f4);
1085
1086    f = native_exp(f);
1087    f2 = native_exp(f2);
1088    f3 = native_exp(f3);
1089    f4 = native_exp(f4);
1090
1091    f = native_exp10(f);
1092    f2 = native_exp10(f2);
1093    f3 = native_exp10(f3);
1094    f4 = native_exp10(f4);
1095
1096    f = native_log2(f);
1097    f2 = native_log2(f2);
1098    f3 = native_log2(f3);
1099    f4 = native_log2(f4);
1100
1101    f = native_log(f);
1102    f2 = native_log(f2);
1103    f3 = native_log(f3);
1104    f4 = native_log(f4);
1105
1106    f = native_log10(f);
1107    f2 = native_log10(f2);
1108    f3 = native_log10(f3);
1109    f4 = native_log10(f4);
1110
1111    f = native_powr(f, f);
1112    f2 = native_powr(f2, f2);
1113    f3 = native_powr(f3, f3);
1114    f4 = native_powr(f4, f4);
1115
1116    // rs_core.rsh
1117    b = rsSendToClient(0);
1118    b = rsSendToClient(0, NULL, 0);
1119    rsSendToClientBlocking(0);
1120    rsSendToClientBlocking(0, NULL, 0);
1121
1122    rs_script_call_t sc;
1123    rsForEach(scriptNonNull, allocNonNull, allocNonNull, NULL, 0, &sc);
1124    rsForEach(scriptNonNull, allocNonNull, allocNonNull, NULL, 0);
1125    rsForEach(scriptNonNull, allocNonNull, allocNonNull);
1126
1127    // rs_debug.rsh
1128    rsDebug("", f);
1129    rsDebug("", f, f);
1130    rsDebug("", f, f, f);
1131    rsDebug("", f, f, f, f);
1132    rsDebug("", f2);
1133    rsDebug("", f3);
1134    rsDebug("", f4);
1135    rsDebug("", d);
1136    rsDebug("", &m4x4);
1137    rsDebug("", &m3x3);
1138    rsDebug("", &m2x2);
1139    rsDebug("", i);
1140    rsDebug("", ui);
1141    rsDebug("", l);
1142    rsDebug("", ul);
1143    rsDebug("", ll);
1144    rsDebug("", ull);
1145    rsDebug("", (const void *)&i);
1146    rsDebug("", c);
1147    rsDebug("", c2);
1148    rsDebug("", c3);
1149    rsDebug("", c4);
1150    rsDebug("", uc);
1151    rsDebug("", uc2);
1152    rsDebug("", uc3);
1153    rsDebug("", uc4);
1154    rsDebug("", s);
1155    rsDebug("", s2);
1156    rsDebug("", s3);
1157    rsDebug("", s4);
1158    rsDebug("", us);
1159    rsDebug("", us2);
1160    rsDebug("", us3);
1161    rsDebug("", us4);
1162    rsDebug("", i2);
1163    rsDebug("", i3);
1164    rsDebug("", i4);
1165    rsDebug("", ui2);
1166    rsDebug("", ui3);
1167    rsDebug("", ui4);
1168    rsDebug("", l2);
1169    rsDebug("", l3);
1170    rsDebug("", l4);
1171    rsDebug("", ul2);
1172    rsDebug("", ul3);
1173    rsDebug("", ul4);
1174
1175    // rs_element.rsh
1176    ui = rsElementGetSubElementCount(elemNonNull);
1177    elemNull = rsElementGetSubElement(elemNonNull, 0);
1178    ui = rsElementGetSubElementNameLength(elemNonNull, 0);
1179    ui = rsElementGetSubElementName(elemNonNull, 0, NULL, 0);
1180    ui = rsElementGetSubElementArraySize(elemNonNull, 0);
1181    ui = rsElementGetSubElementOffsetBytes(elemNonNull, 0);
1182    ui = rsElementGetBytesSize(elemNonNull);
1183
1184    dt = rsElementGetDataType(elemNonNull);
1185    dk = rsElementGetDataKind(elemNonNull);
1186
1187    ui = rsElementGetVectorSize(elemNonNull);
1188
1189    // rs_math.rsh
1190    i = rsRand(i);
1191    i = rsRand(i, i);
1192    f = rsRand(f);
1193    f = rsFrac(f);
1194    ui = rsClamp(ui, ui, ui);
1195    i = rsClamp(i, i, i);
1196    us = rsClamp(us, us, us);
1197    s = rsClamp(s, s, s);
1198    uc = rsClamp(uc, uc, uc);
1199    c = rsClamp(c, c, c);
1200
1201    // skip always-inlined rsExtractFrustumPlanes
1202    // skip always-inlined rsIsSphereInFrustum
1203
1204    uc4 = rsPackColorTo8888(f, f, f);
1205    uc4 = rsPackColorTo8888(f, f, f, f);
1206    uc4 = rsPackColorTo8888(f3);
1207    uc4 = rsPackColorTo8888(f4);
1208    f4 = rsUnpackColor8888(uc4);
1209    uc4 = rsYuvToRGBA_uchar4(uc, uc, uc);
1210    f4 = rsYuvToRGBA_float4(uc, uc, uc);
1211
1212    // rs_matrix.rsh
1213    rsMatrixSet(&m4x4, ui, ui, f);
1214    rsMatrixSet(&m3x3, ui, ui, f);
1215    rsMatrixSet(&m2x2, ui, ui, f);
1216    f = rsMatrixGet(&m4x4, ui, ui);
1217    f = rsMatrixGet(&m3x3, ui, ui);
1218    f = rsMatrixGet(&m2x2, ui, ui);
1219    rsMatrixLoadIdentity(&m4x4);
1220    rsMatrixLoadIdentity(&m3x3);
1221    rsMatrixLoadIdentity(&m2x2);
1222    rsMatrixLoad(&m4x4, fa);
1223    rsMatrixLoad(&m3x3, fa);
1224    rsMatrixLoad(&m2x2, fa);
1225    rsMatrixLoad(&m4x4, &m4x4);
1226    rsMatrixLoad(&m4x4, &m3x3);
1227    rsMatrixLoad(&m4x4, &m2x2);
1228    rsMatrixLoad(&m3x3, &m3x3);
1229    rsMatrixLoad(&m2x2, &m2x2);
1230    rsMatrixLoadRotate(&m4x4, f, f, f, f);
1231    rsMatrixLoadScale(&m4x4, f, f, f);
1232    rsMatrixLoadTranslate(&m4x4, f, f, f);
1233    rsMatrixLoadMultiply(&m4x4, &m4x4, &m4x4);
1234    rsMatrixLoadMultiply(&m3x3, &m3x3, &m3x3);
1235    rsMatrixLoadMultiply(&m2x2, &m2x2, &m2x2);
1236    rsMatrixMultiply(&m4x4, &m4x4);
1237    rsMatrixMultiply(&m3x3, &m3x3);
1238    rsMatrixMultiply(&m2x2, &m2x2);
1239    rsMatrixRotate(&m4x4, f, f, f, f);
1240    rsMatrixScale(&m4x4, f, f, f);
1241    rsMatrixTranslate(&m4x4, f, f, f);
1242    rsMatrixLoadOrtho(&m4x4, f, f, f, f, f, f);
1243    rsMatrixLoadFrustum(&m4x4, f, f, f, f, f, f);
1244    rsMatrixLoadPerspective(&m4x4, f, f, f, f);
1245    f4 = rsMatrixMultiply(&m4x4, f4);
1246    f4 = rsMatrixMultiply(&m4x4, f3);
1247    f4 = rsMatrixMultiply(&m4x4, f2);
1248    f3 = rsMatrixMultiply(&m3x3, f3);
1249    f3 = rsMatrixMultiply(&m3x3, f2);
1250    f2 = rsMatrixMultiply(&m2x2, f2);
1251    b = rsMatrixInverse(&m4x4);
1252    b = rsMatrixInverseTranspose(&m4x4);
1253    rsMatrixTranspose(&m4x4);
1254    rsMatrixTranspose(&m3x3);
1255    rsMatrixTranspose(&m2x2);
1256
1257    // rs_object.rsh
1258    rsSetObject(&elemNonNull, elemNonNull);
1259    rsSetObject(&typeNonNull, typeNonNull);
1260    rsSetObject(&allocNonNull, allocNonNull);
1261    rsSetObject(&samplerNonNull, samplerNonNull);
1262    rsSetObject(&scriptNonNull, scriptNonNull);
1263    rsClearObject(&elemNonNull);
1264    rsClearObject(&typeNonNull);
1265    rsClearObject(&allocNonNull);
1266    rsClearObject(&samplerNonNull);
1267    rsClearObject(&scriptNonNull);
1268    b = rsIsObject(elemNonNull);
1269    b = rsIsObject(typeNonNull);
1270    b = rsIsObject(allocNonNull);
1271    b = rsIsObject(samplerNonNull);
1272    b = rsIsObject(scriptNonNull);
1273
1274    // rs_quaternion.rsh skipped because all functions are static.
1275
1276    // rs_sampler.rsh
1277    rsv = rsSamplerGetMinification(samplerNonNull);
1278    rsv = rsSamplerGetMagnification(samplerNonNull);
1279    rsv = rsSamplerGetWrapS(samplerNonNull);
1280    rsv = rsSamplerGetWrapT(samplerNonNull);
1281    f = rsSamplerGetAnisotropy(samplerNonNull);
1282
1283    // rs_time.rsh
1284    rst = rsTime(NULL);
1285    rsLocaltime((rs_tm *) &rstm, (rs_time_t *) &rst);
1286    ll = rsUptimeMillis();
1287    ll = rsUptimeNanos();
1288    f = rsGetDt();
1289
1290    /********************************
1291     * DO NOT EXECUTE THIS FUNCTION *
1292     ********************************/
1293}
1294
1295static bool test_obj_api() {
1296    bool failed = false;
1297
1298    _RS_ASSERT(!rsIsObject(elemNull));
1299    _RS_ASSERT(rsIsObject(elemNonNull));
1300    rsSetObject(&elemNull, elemNonNull);
1301    _RS_ASSERT(rsIsObject(elemNull));
1302    rsClearObject(&elemNull);
1303    _RS_ASSERT(!rsIsObject(elemNull));
1304
1305    _RS_ASSERT(!rsIsObject(typeNull));
1306    _RS_ASSERT(rsIsObject(typeNonNull));
1307    rsSetObject(&typeNull, typeNonNull);
1308    _RS_ASSERT(rsIsObject(typeNull));
1309    rsClearObject(&typeNull);
1310    _RS_ASSERT(!rsIsObject(typeNull));
1311
1312    _RS_ASSERT(!rsIsObject(allocNull));
1313    _RS_ASSERT(rsIsObject(allocNonNull));
1314    rsSetObject(&allocNull, allocNonNull);
1315    _RS_ASSERT(rsIsObject(allocNull));
1316    rsClearObject(&allocNull);
1317    _RS_ASSERT(!rsIsObject(allocNull));
1318
1319    _RS_ASSERT(!rsIsObject(samplerNull));
1320    _RS_ASSERT(rsIsObject(samplerNonNull));
1321    rsSetObject(&samplerNull, samplerNonNull);
1322    _RS_ASSERT(rsIsObject(samplerNull));
1323    rsClearObject(&samplerNull);
1324    _RS_ASSERT(!rsIsObject(samplerNull));
1325
1326    _RS_ASSERT(!rsIsObject(scriptNull));
1327    _RS_ASSERT(rsIsObject(scriptNonNull));
1328    rsSetObject(&scriptNull, scriptNonNull);
1329    _RS_ASSERT(rsIsObject(scriptNull));
1330    rsClearObject(&scriptNull);
1331    _RS_ASSERT(!rsIsObject(scriptNull));
1332
1333    if (failed) {
1334        rsDebug("test_obj_api FAILED", -1);
1335    }
1336    else {
1337        rsDebug("test_obj_api PASSED", 0);
1338    }
1339
1340    return failed;
1341}
1342
1343
1344static bool test_rs_alloc_api() {
1345    bool failed = false;
1346    rs_allocation a = rsGetAllocation(allocPtr);
1347    _RS_ASSERT(rsIsObject(a));
1348    _RS_ASSERT(rsAllocationGetDimX(a) == x);
1349    _RS_ASSERT(rsAllocationGetDimY(a) == y);
1350    _RS_ASSERT(rsAllocationGetDimZ(a) == z);
1351    _RS_ASSERT(rsAllocationGetDimLOD(a) == 0);
1352    _RS_ASSERT(rsAllocationGetDimFaces(a) == 0);
1353
1354    rsSetElementAt_char(a, 5, 1, 0);
1355    rsAllocationCopy1DRange(allocDst, 0, 0, x, a, 0, 0);
1356    _RS_ASSERT(rsGetElementAt_char(allocDst, 1, 0) == 5);
1357
1358    if (failed) {
1359        rsDebug("test_obj_api FAILED", -1);
1360    }
1361    else {
1362        rsDebug("test_obj_api PASSED", 0);
1363    }
1364
1365    return failed;
1366}
1367
1368
1369void api_test() {
1370    bool failed = false;
1371    failed |= test_obj_api();
1372    failed |= test_rs_alloc_api();
1373
1374    if (failed) {
1375        rsSendToClientBlocking(RS_MSG_TEST_FAILED);
1376    }
1377    else {
1378        rsSendToClientBlocking(RS_MSG_TEST_PASSED);
1379    }
1380}
1381
1382