blob: 41828dc2afa7bff72af267db869458f647080391 [file] [log] [blame]
Jason Samse45ac6e2009-07-20 14:31:06 -07001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "rsContext.h"
18#include "rsScriptC.h"
19#include "rsMatrix.h"
20
Joe Onorato9c4e4ca2009-08-09 11:39:02 -070021#include "utils/Timers.h"
Jason Samse45ac6e2009-07-20 14:31:06 -070022
Romain Guy98e10fd2009-07-30 18:45:01 -070023#include <time.h>
Romain Guy98e10fd2009-07-30 18:45:01 -070024
Jason Samse45ac6e2009-07-20 14:31:06 -070025using namespace android;
26using namespace android::renderscript;
27
28#define GET_TLS() Context::ScriptTLSStruct * tls = \
29 (Context::ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey); \
30 Context * rsc = tls->mContext; \
31 ScriptC * sc = (ScriptC *) tls->mScript
32
Jason Samsbe36bf32010-05-11 14:03:58 -070033
Jason Samse45ac6e2009-07-20 14:31:06 -070034//////////////////////////////////////////////////////////////////////////////
35// Math routines
36//////////////////////////////////////////////////////////////////////////////
37
Romain Guy2275d632009-08-18 11:39:17 -070038static float SC_sinf_fast(float x)
39{
40 const float A = 1.0f / (2.0f * M_PI);
41 const float B = -16.0f;
42 const float C = 8.0f;
Jason Samsa57c0a72009-09-04 14:42:41 -070043
Romain Guy2275d632009-08-18 11:39:17 -070044 // scale angle for easy argument reduction
45 x *= A;
Jason Samsa57c0a72009-09-04 14:42:41 -070046
Romain Guy2275d632009-08-18 11:39:17 -070047 if (fabsf(x) >= 0.5f) {
48 // argument reduction
49 x = x - ceilf(x + 0.5f) + 1.0f;
50 }
Jason Samsa57c0a72009-09-04 14:42:41 -070051
Romain Guy2275d632009-08-18 11:39:17 -070052 const float y = B * x * fabsf(x) + C * x;
53 return 0.2215f * (y * fabsf(y) - y) + y;
54}
55
56static float SC_cosf_fast(float x)
57{
58 x += float(M_PI / 2);
59
60 const float A = 1.0f / (2.0f * M_PI);
61 const float B = -16.0f;
62 const float C = 8.0f;
Jason Samsa57c0a72009-09-04 14:42:41 -070063
Romain Guy2275d632009-08-18 11:39:17 -070064 // scale angle for easy argument reduction
65 x *= A;
Jason Samsa57c0a72009-09-04 14:42:41 -070066
Romain Guy2275d632009-08-18 11:39:17 -070067 if (fabsf(x) >= 0.5f) {
68 // argument reduction
69 x = x - ceilf(x + 0.5f) + 1.0f;
70 }
Jason Samsa57c0a72009-09-04 14:42:41 -070071
Romain Guy2275d632009-08-18 11:39:17 -070072 const float y = B * x * fabsf(x) + C * x;
73 return 0.2215f * (y * fabsf(y) - y) + y;
74}
75
Jason Sams22fa3712010-05-19 17:22:57 -070076
Jason Samse45ac6e2009-07-20 14:31:06 -070077static float SC_randf(float max)
78{
79 float r = (float)rand();
80 return r / RAND_MAX * max;
81}
82
Romain Guy39dbc802009-07-31 11:20:59 -070083static float SC_randf2(float min, float max)
84{
85 float r = (float)rand();
86 return r / RAND_MAX * (max - min) + min;
87}
88
Jason Sams22fa3712010-05-19 17:22:57 -070089static int SC_randi(int max)
90{
91 return (int)SC_randf(max);
92}
93
94static int SC_randi2(int min, int max)
95{
96 return (int)SC_randf2(min, max);
97}
98
Jason Samsbe36bf32010-05-11 14:03:58 -070099static float SC_frac(float v)
100{
101 int i = (int)floor(v);
102 return fmin(v - i, 0x1.fffffep-1f);
103}
104
Romain Guy98e10fd2009-07-30 18:45:01 -0700105//////////////////////////////////////////////////////////////////////////////
106// Time routines
107//////////////////////////////////////////////////////////////////////////////
Jason Samse45ac6e2009-07-20 14:31:06 -0700108
Joe Onorato9c4e4ca2009-08-09 11:39:02 -0700109static int32_t SC_second()
Romain Guy98e10fd2009-07-30 18:45:01 -0700110{
111 GET_TLS();
112
113 time_t rawtime;
114 time(&rawtime);
115
Romain Guy519cdc92009-11-11 15:36:06 -0800116 struct tm *timeinfo;
117 timeinfo = localtime(&rawtime);
118 return timeinfo->tm_sec;
Romain Guy98e10fd2009-07-30 18:45:01 -0700119}
120
Joe Onorato9c4e4ca2009-08-09 11:39:02 -0700121static int32_t SC_minute()
Romain Guy98e10fd2009-07-30 18:45:01 -0700122{
123 GET_TLS();
Jason Samse5ffb872009-08-09 17:01:55 -0700124
Romain Guy98e10fd2009-07-30 18:45:01 -0700125 time_t rawtime;
126 time(&rawtime);
Jason Samse5ffb872009-08-09 17:01:55 -0700127
Romain Guy519cdc92009-11-11 15:36:06 -0800128 struct tm *timeinfo;
129 timeinfo = localtime(&rawtime);
130 return timeinfo->tm_min;
Jason Samse5ffb872009-08-09 17:01:55 -0700131}
Romain Guy98e10fd2009-07-30 18:45:01 -0700132
Joe Onorato9c4e4ca2009-08-09 11:39:02 -0700133static int32_t SC_hour()
Romain Guy98e10fd2009-07-30 18:45:01 -0700134{
135 GET_TLS();
Jason Samse5ffb872009-08-09 17:01:55 -0700136
Romain Guy98e10fd2009-07-30 18:45:01 -0700137 time_t rawtime;
138 time(&rawtime);
Jason Samse5ffb872009-08-09 17:01:55 -0700139
Romain Guy519cdc92009-11-11 15:36:06 -0800140 struct tm *timeinfo;
141 timeinfo = localtime(&rawtime);
142 return timeinfo->tm_hour;
Romain Guy39dbc802009-07-31 11:20:59 -0700143}
144
Joe Onorato9c4e4ca2009-08-09 11:39:02 -0700145static int32_t SC_day()
Romain Guy39dbc802009-07-31 11:20:59 -0700146{
147 GET_TLS();
Jason Samse5ffb872009-08-09 17:01:55 -0700148
Romain Guy39dbc802009-07-31 11:20:59 -0700149 time_t rawtime;
150 time(&rawtime);
Jason Samse5ffb872009-08-09 17:01:55 -0700151
Romain Guy519cdc92009-11-11 15:36:06 -0800152 struct tm *timeinfo;
153 timeinfo = localtime(&rawtime);
154 return timeinfo->tm_mday;
Jason Samse5ffb872009-08-09 17:01:55 -0700155}
Jason Samse45ac6e2009-07-20 14:31:06 -0700156
Joe Onorato9c4e4ca2009-08-09 11:39:02 -0700157static int32_t SC_month()
Romain Guy39dbc802009-07-31 11:20:59 -0700158{
159 GET_TLS();
Jason Samse5ffb872009-08-09 17:01:55 -0700160
Romain Guy39dbc802009-07-31 11:20:59 -0700161 time_t rawtime;
162 time(&rawtime);
Jason Samse5ffb872009-08-09 17:01:55 -0700163
Romain Guy519cdc92009-11-11 15:36:06 -0800164 struct tm *timeinfo;
165 timeinfo = localtime(&rawtime);
166 return timeinfo->tm_mon;
Jason Samse5ffb872009-08-09 17:01:55 -0700167}
Romain Guy39dbc802009-07-31 11:20:59 -0700168
Joe Onorato9c4e4ca2009-08-09 11:39:02 -0700169static int32_t SC_year()
Romain Guy39dbc802009-07-31 11:20:59 -0700170{
171 GET_TLS();
Jason Samse5ffb872009-08-09 17:01:55 -0700172
Romain Guy39dbc802009-07-31 11:20:59 -0700173 time_t rawtime;
174 time(&rawtime);
Jason Samse5ffb872009-08-09 17:01:55 -0700175
Romain Guy519cdc92009-11-11 15:36:06 -0800176 struct tm *timeinfo;
177 timeinfo = localtime(&rawtime);
178 return timeinfo->tm_year;
Romain Guy39dbc802009-07-31 11:20:59 -0700179}
180
Jason Samsef5867a2010-07-28 11:17:53 -0700181static int64_t SC_uptimeMillis()
Jason Sams22fa3712010-05-19 17:22:57 -0700182{
183 return nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC));
184}
185
Jason Sams73495472010-07-29 17:31:14 -0700186static int64_t SC_uptimeNanos()
Jason Sams22fa3712010-05-19 17:22:57 -0700187{
Jason Sams73495472010-07-29 17:31:14 -0700188 return systemTime(SYSTEM_TIME_MONOTONIC);
Jason Sams22fa3712010-05-19 17:22:57 -0700189}
190
Jason Samsef5867a2010-07-28 11:17:53 -0700191static float SC_getDt()
Joe Onorato9c4e4ca2009-08-09 11:39:02 -0700192{
193 GET_TLS();
Jason Samsef5867a2010-07-28 11:17:53 -0700194 int64_t l = sc->mEnviroment.mLastDtTime;
195 sc->mEnviroment.mLastDtTime = systemTime(SYSTEM_TIME_MONOTONIC);
196 return ((float)(sc->mEnviroment.mLastDtTime - l)) / 1.0e9;
Jason Samse45ac6e2009-07-20 14:31:06 -0700197}
198
199
Jason Samse45ac6e2009-07-20 14:31:06 -0700200//////////////////////////////////////////////////////////////////////////////
201//
202//////////////////////////////////////////////////////////////////////////////
203
Jason Samsbe36bf32010-05-11 14:03:58 -0700204static uint32_t SC_allocGetDimX(RsAllocation va)
205{
206 GET_TLS();
207 const Allocation *a = static_cast<const Allocation *>(va);
208 //LOGE("SC_allocGetDimX a=%p", a);
209 //LOGE(" type=%p", a->getType());
210 return a->getType()->getDimX();
211}
212
213static uint32_t SC_allocGetDimY(RsAllocation va)
214{
215 GET_TLS();
216 const Allocation *a = static_cast<const Allocation *>(va);
217 return a->getType()->getDimY();
218}
219
220static uint32_t SC_allocGetDimZ(RsAllocation va)
221{
222 GET_TLS();
223 const Allocation *a = static_cast<const Allocation *>(va);
224 return a->getType()->getDimZ();
225}
226
227static uint32_t SC_allocGetDimLOD(RsAllocation va)
228{
229 GET_TLS();
230 const Allocation *a = static_cast<const Allocation *>(va);
231 return a->getType()->getDimLOD();
232}
233
234static uint32_t SC_allocGetDimFaces(RsAllocation va)
235{
236 GET_TLS();
237 const Allocation *a = static_cast<const Allocation *>(va);
238 return a->getType()->getDimFaces();
239}
240
Jason Samsc0936852010-08-16 12:41:48 -0700241static const void * SC_getElementAtX(RsAllocation va, uint32_t x)
Jason Sams7bf29dd2010-07-19 15:38:19 -0700242{
243 const Allocation *a = static_cast<const Allocation *>(va);
244 const Type *t = a->getType();
245 const uint8_t *p = (const uint8_t *)a->getPtr();
246 return &p[t->getElementSizeBytes() * x];
247}
248
Jason Samsc0936852010-08-16 12:41:48 -0700249static const void * SC_getElementAtXY(RsAllocation va, uint32_t x, uint32_t y)
Jason Sams7bf29dd2010-07-19 15:38:19 -0700250{
251 const Allocation *a = static_cast<const Allocation *>(va);
252 const Type *t = a->getType();
253 const uint8_t *p = (const uint8_t *)a->getPtr();
254 return &p[t->getElementSizeBytes() * (x + y*t->getDimX())];
255}
256
Jason Samsc0936852010-08-16 12:41:48 -0700257static const void * SC_getElementAtXYZ(RsAllocation va, uint32_t x, uint32_t y, uint32_t z)
Jason Sams7bf29dd2010-07-19 15:38:19 -0700258{
259 const Allocation *a = static_cast<const Allocation *>(va);
260 const Type *t = a->getType();
261 const uint8_t *p = (const uint8_t *)a->getPtr();
262 return &p[t->getElementSizeBytes() * (x + y*t->getDimX())];
263}
Jason Samsbe36bf32010-05-11 14:03:58 -0700264
Jason Samsc0936852010-08-16 12:41:48 -0700265static void SC_setObject(void **vdst, void * vsrc) {
266 static_cast<ObjectBase *>(vsrc)->incSysRef();
267 static_cast<ObjectBase *>(vdst[0])->decSysRef();
268 *vdst = vsrc;
269}
270static void SC_clearObject(void **vdst) {
271 static_cast<ObjectBase *>(vdst[0])->decSysRef();
272 *vdst = NULL;
273}
274static bool SC_isObject(RsAllocation vsrc) {
275 return vsrc != NULL;
276}
277
278
Jason Samse45ac6e2009-07-20 14:31:06 -0700279
Jason Sams22fa3712010-05-19 17:22:57 -0700280static void SC_debugF(const char *s, float f) {
281 LOGE("%s %f, 0x%08x", s, f, *((int *) (&f)));
Jason Samsc9d43db2009-07-28 12:02:16 -0700282}
Jason Sams7dce6bc2010-08-06 16:22:50 -0700283static void SC_debugFv2(const char *s, float f1, float f2) {
284 LOGE("%s {%f, %f}", s, f1, f2);
Romain Guy370ed152009-08-20 17:08:33 -0700285}
Jason Sams7dce6bc2010-08-06 16:22:50 -0700286static void SC_debugFv3(const char *s, float f1, float f2, float f3) {
287 LOGE("%s {%f, %f, %f}", s, f1, f2, f3);
Jason Samsc9d43db2009-07-28 12:02:16 -0700288}
Jason Sams7dce6bc2010-08-06 16:22:50 -0700289static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) {
290 LOGE("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4);
Jason Sams22fa3712010-05-19 17:22:57 -0700291}
Jason Sams7dce6bc2010-08-06 16:22:50 -0700292static void SC_debugFM4v4(const char *s, const float *f) {
293 LOGE("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]);
294 LOGE("%s %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]);
295 LOGE("%s %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]);
296 LOGE("%s %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]);
297}
298static void SC_debugFM3v3(const char *s, const float *f) {
299 LOGE("%s {%f, %f, %f", s, f[0], f[3], f[6]);
300 LOGE("%s %f, %f, %f", s, f[1], f[4], f[7]);
301 LOGE("%s %f, %f, %f}",s, f[2], f[5], f[8]);
302}
303static void SC_debugFM2v2(const char *s, const float *f) {
304 LOGE("%s {%f, %f", s, f[0], f[2]);
305 LOGE("%s %f, %f}",s, f[1], f[3]);
306}
307
Jason Sams22fa3712010-05-19 17:22:57 -0700308static void SC_debugI32(const char *s, int32_t i) {
309 LOGE("%s %i 0x%x", s, i, i);
Romain Guy370ed152009-08-20 17:08:33 -0700310}
Jason Samsef5867a2010-07-28 11:17:53 -0700311static void SC_debugU32(const char *s, uint32_t i) {
312 LOGE("%s %i 0x%x", s, i, i);
313}
Romain Guy370ed152009-08-20 17:08:33 -0700314
Jason Sams7bf29dd2010-07-19 15:38:19 -0700315static void SC_debugP(const char *s, const void *p) {
316 LOGE("%s %p", s, p);
317}
318
Jason Samsef5867a2010-07-28 11:17:53 -0700319static uint32_t SC_toClient2(int cmdID, void *data, int len)
Jason Sams8c401ef2009-10-06 13:58:47 -0700320{
321 GET_TLS();
Jason Samsef5867a2010-07-28 11:17:53 -0700322 //LOGE("SC_toClient %i %i %i", cmdID, len);
323 return rsc->sendMessageToClient(data, cmdID, len, false);
Jason Sams8c401ef2009-10-06 13:58:47 -0700324}
325
Jason Samsef5867a2010-07-28 11:17:53 -0700326static uint32_t SC_toClient(int cmdID)
Jason Sams3a27c952009-10-07 18:14:01 -0700327{
328 GET_TLS();
Jason Samsef5867a2010-07-28 11:17:53 -0700329 //LOGE("SC_toClient %i", cmdID);
330 return rsc->sendMessageToClient(NULL, cmdID, 0, false);
331}
332
333static uint32_t SC_toClientBlocking2(int cmdID, void *data, int len)
334{
335 GET_TLS();
336 //LOGE("SC_toClientBlocking %i %i", cmdID, len);
337 return rsc->sendMessageToClient(data, cmdID, len, true);
338}
339
340static uint32_t SC_toClientBlocking(int cmdID)
341{
342 GET_TLS();
343 //LOGE("SC_toClientBlocking %i", cmdID);
344 return rsc->sendMessageToClient(NULL, cmdID, 0, true);
Jason Sams3a27c952009-10-07 18:14:01 -0700345}
346
Jason Samsbe36bf32010-05-11 14:03:58 -0700347int SC_divsi3(int a, int b)
348{
349 return a / b;
350}
Jason Sams3a27c952009-10-07 18:14:01 -0700351
Jason Samsce92d4b2010-05-17 14:55:34 -0700352int SC_getAllocation(const void *ptr)
353{
354 GET_TLS();
355 const Allocation *alloc = sc->ptrToAllocation(ptr);
356 return (int)alloc;
357}
358
Alex Sakhartchouk1e5168d2010-09-01 16:34:48 -0700359void SC_allocationMarkDirty(RsAllocation a)
360{
361 Allocation *alloc = static_cast<Allocation *>(a);
362 alloc->sendDirty();
363}
Jason Samsce92d4b2010-05-17 14:55:34 -0700364
Jason Samsace3e012010-07-15 17:11:13 -0700365void SC_ForEach(RsScript vs,
366 RsAllocation vin,
367 RsAllocation vout,
368 const void *usr)
Jason Samsc61346b2010-05-28 18:23:22 -0700369{
370 GET_TLS();
Jason Samsace3e012010-07-15 17:11:13 -0700371 const Allocation *ain = static_cast<const Allocation *>(vin);
Jason Samsc61346b2010-05-28 18:23:22 -0700372 Allocation *aout = static_cast<Allocation *>(vout);
Jason Samsace3e012010-07-15 17:11:13 -0700373 Script *s = static_cast<Script *>(vs);
374 s->runForEach(rsc, ain, aout, usr);
Jason Samsc61346b2010-05-28 18:23:22 -0700375}
376
Jason Samsace3e012010-07-15 17:11:13 -0700377void SC_ForEach2(RsScript vs,
378 RsAllocation vin,
379 RsAllocation vout,
380 const void *usr,
381 const RsScriptCall *call)
Jason Samsc61346b2010-05-28 18:23:22 -0700382{
383 GET_TLS();
Jason Samsace3e012010-07-15 17:11:13 -0700384 const Allocation *ain = static_cast<const Allocation *>(vin);
Jason Samsc61346b2010-05-28 18:23:22 -0700385 Allocation *aout = static_cast<Allocation *>(vout);
Jason Samsc61346b2010-05-28 18:23:22 -0700386 Script *s = static_cast<Script *>(vs);
Jason Samsace3e012010-07-15 17:11:13 -0700387 s->runForEach(rsc, ain, aout, usr, call);
Jason Samsc61346b2010-05-28 18:23:22 -0700388}
389
Jason Samse45ac6e2009-07-20 14:31:06 -0700390//////////////////////////////////////////////////////////////////////////////
391// Class implementation
392//////////////////////////////////////////////////////////////////////////////
393
Jason Samsbe36bf32010-05-11 14:03:58 -0700394// llvm name mangling ref
395// <builtin-type> ::= v # void
396// ::= b # bool
397// ::= c # char
398// ::= a # signed char
399// ::= h # unsigned char
400// ::= s # short
401// ::= t # unsigned short
402// ::= i # int
403// ::= j # unsigned int
404// ::= l # long
405// ::= m # unsigned long
406// ::= x # long long, __int64
407// ::= y # unsigned long long, __int64
408// ::= f # float
409// ::= d # double
Jason Samse45ac6e2009-07-20 14:31:06 -0700410
Jason Samsaeb094b2010-05-18 13:35:45 -0700411static ScriptCState::SymbolTable_t gSyms[] = {
Jason Samsbe36bf32010-05-11 14:03:58 -0700412 { "__divsi3", (void *)&SC_divsi3 },
413
Jason Sams22fa3712010-05-19 17:22:57 -0700414 // allocation
Jason Samsef5867a2010-07-28 11:17:53 -0700415 { "_Z19rsAllocationGetDimX13rs_allocation", (void *)&SC_allocGetDimX },
416 { "_Z19rsAllocationGetDimY13rs_allocation", (void *)&SC_allocGetDimY },
417 { "_Z19rsAllocationGetDimZ13rs_allocation", (void *)&SC_allocGetDimZ },
418 { "_Z21rsAllocationGetDimLOD13rs_allocation", (void *)&SC_allocGetDimLOD },
419 { "_Z23rsAllocationGetDimFaces13rs_allocation", (void *)&SC_allocGetDimFaces },
420 { "_Z15rsGetAllocationPKv", (void *)&SC_getAllocation },
Jason Sams22fa3712010-05-19 17:22:57 -0700421
Jason Sams7bf29dd2010-07-19 15:38:19 -0700422 { "_Z14rsGetElementAt13rs_allocationj", (void *)&SC_getElementAtX },
423 { "_Z14rsGetElementAt13rs_allocationjj", (void *)&SC_getElementAtXY },
424 { "_Z14rsGetElementAt13rs_allocationjjj", (void *)&SC_getElementAtXYZ },
425
Jason Samsc0936852010-08-16 12:41:48 -0700426 { "_Z11rsSetObjectP13rs_allocation13rs_allocation", (void *)&SC_setObject },
427 { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_clearObject },
428 { "_Z10rsIsObject13rs_allocation", (void *)&SC_isObject },
429
Alex Sakhartchouk1e5168d2010-09-01 16:34:48 -0700430 { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_allocationMarkDirty },
431
Jason Samsc0936852010-08-16 12:41:48 -0700432
Jason Sams22fa3712010-05-19 17:22:57 -0700433 // Debug
434 { "_Z7rsDebugPKcf", (void *)&SC_debugF },
Jason Sams7dce6bc2010-08-06 16:22:50 -0700435 { "_Z7rsDebugPKcff", (void *)&SC_debugFv2 },
436 { "_Z7rsDebugPKcfff", (void *)&SC_debugFv3 },
437 { "_Z7rsDebugPKcffff", (void *)&SC_debugFv4 },
438 { "_Z7rsDebugPKcPK12rs_matrix4x4", (void *)&SC_debugFM4v4 },
439 { "_Z7rsDebugPKcPK12rs_matrix3x3", (void *)&SC_debugFM3v3 },
440 { "_Z7rsDebugPKcPK12rs_matrix2x2", (void *)&SC_debugFM2v2 },
Jason Sams22fa3712010-05-19 17:22:57 -0700441 { "_Z7rsDebugPKci", (void *)&SC_debugI32 },
Jason Samsef5867a2010-07-28 11:17:53 -0700442 { "_Z7rsDebugPKcj", (void *)&SC_debugU32 },
Jason Sams7bf29dd2010-07-19 15:38:19 -0700443 { "_Z7rsDebugPKcPKv", (void *)&SC_debugP },
Jason Sams22fa3712010-05-19 17:22:57 -0700444
445 // RS Math
446 { "_Z6rsRandi", (void *)&SC_randi },
447 { "_Z6rsRandii", (void *)&SC_randi2 },
448 { "_Z6rsRandf", (void *)&SC_randf },
449 { "_Z6rsRandff", (void *)&SC_randf2 },
450 { "_Z6rsFracf", (void *)&SC_frac },
451
452 // time
Jason Sams73495472010-07-29 17:31:14 -0700453 { "_Z8rsSecondv", (void *)&SC_second },
454 { "_Z8rsMinutev", (void *)&SC_minute },
455 { "_Z6rsHourv", (void *)&SC_hour },
456 { "_Z5rsDayv", (void *)&SC_day },
457 { "_Z7rsMonthv", (void *)&SC_month },
458 { "_Z6rsYearv", (void *)&SC_year },
459 { "_Z14rsUptimeMillisv", (void*)&SC_uptimeMillis },
460 { "_Z13rsUptimeNanosv", (void*)&SC_uptimeNanos },
461 { "_Z7rsGetDtv", (void*)&SC_getDt },
Jason Sams22fa3712010-05-19 17:22:57 -0700462
Jason Samsef5867a2010-07-28 11:17:53 -0700463 { "_Z14rsSendToClienti", (void *)&SC_toClient },
464 { "_Z14rsSendToClientiPKvj", (void *)&SC_toClient2 },
465 { "_Z22rsSendToClientBlockingi", (void *)&SC_toClientBlocking },
466 { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_toClientBlocking2 },
Jason Sams22fa3712010-05-19 17:22:57 -0700467
Jason Samsace3e012010-07-15 17:11:13 -0700468 { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach },
469 //{ "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach2 },
Jason Sams22fa3712010-05-19 17:22:57 -0700470
471////////////////////////////////////////////////////////////////////
472
Jason Samsbe36bf32010-05-11 14:03:58 -0700473 //{ "sinf_fast", (void *)&SC_sinf_fast },
474 //{ "cosf_fast", (void *)&SC_cosf_fast },
Jason Samse45ac6e2009-07-20 14:31:06 -0700475
Jason Samsbe36bf32010-05-11 14:03:58 -0700476 { NULL, NULL }
Jason Samse45ac6e2009-07-20 14:31:06 -0700477};
478
479const ScriptCState::SymbolTable_t * ScriptCState::lookupSymbol(const char *sym)
480{
481 ScriptCState::SymbolTable_t *syms = gSyms;
482
483 while (syms->mPtr) {
484 if (!strcmp(syms->mName, sym)) {
485 return syms;
486 }
487 syms++;
488 }
489 return NULL;
490}
491