blob: e44c051c1fd8791d83999ed55000b3021322d240 [file] [log] [blame]
Jason Sams9df3b2b2011-08-08 14:31:25 -07001/** @file rs_math.rsh
2 * \brief todo-jsams
3 *
4 * todo-jsams
5 *
6 */
Jason Samsc4cdf452010-07-07 11:55:51 -07007#ifndef __RS_MATH_RSH__
8#define __RS_MATH_RSH__
9
Jason Sams9df3b2b2011-08-08 14:31:25 -070010
11
12/**
13 * \overload
14 */
15extern void __attribute__((overloadable))
16 rsSetObject(rs_element *dst, rs_element src);
17/**
18 * \overload
19 */
20extern void __attribute__((overloadable))
21 rsSetObject(rs_type *dst, rs_type src);
22/**
23 * \overload
24 */
25extern void __attribute__((overloadable))
26 rsSetObject(rs_allocation *dst, rs_allocation src);
27/**
28 * \overload
29 */
30extern void __attribute__((overloadable))
31 rsSetObject(rs_sampler *dst, rs_sampler src);
32/**
33 * \overload
34 */
35extern void __attribute__((overloadable))
36 rsSetObject(rs_script *dst, rs_script src);
37/**
38 * \overload
39 */
40extern void __attribute__((overloadable))
41 rsSetObject(rs_mesh *dst, rs_mesh src);
Jason Sams09aeb8a2011-01-28 15:49:07 -080042/**
43 * Copy reference to the specified object.
44 *
45 * @param dst
46 * @param src
47 */
Jason Samsc0936852010-08-16 12:41:48 -070048extern void __attribute__((overloadable))
Jason Samsc0936852010-08-16 12:41:48 -070049 rsSetObject(rs_program_fragment *dst, rs_program_fragment src);
Jason Sams9df3b2b2011-08-08 14:31:25 -070050/**
51 * \overload
52 */
Jason Samsc0936852010-08-16 12:41:48 -070053extern void __attribute__((overloadable))
54 rsSetObject(rs_program_vertex *dst, rs_program_vertex src);
Jason Sams9df3b2b2011-08-08 14:31:25 -070055/**
56 * \overload
57 */
Jason Samsc0936852010-08-16 12:41:48 -070058extern void __attribute__((overloadable))
59 rsSetObject(rs_program_raster *dst, rs_program_raster src);
Jason Sams9df3b2b2011-08-08 14:31:25 -070060/**
61 * \overload
62 */
Jason Samsc0936852010-08-16 12:41:48 -070063extern void __attribute__((overloadable))
64 rsSetObject(rs_program_store *dst, rs_program_store src);
Jason Sams9df3b2b2011-08-08 14:31:25 -070065/**
66 * \overload
67 */
Jason Samsc0936852010-08-16 12:41:48 -070068extern void __attribute__((overloadable))
69 rsSetObject(rs_font *dst, rs_font src);
70
Jason Sams09aeb8a2011-01-28 15:49:07 -080071/**
72 * Sets the object to NULL.
73 *
74 * @return bool
75 */
Jason Samsc0936852010-08-16 12:41:48 -070076extern void __attribute__((overloadable))
77 rsClearObject(rs_element *dst);
Jason Sams9df3b2b2011-08-08 14:31:25 -070078/**
79 * \overload
80 */
Jason Samsc0936852010-08-16 12:41:48 -070081extern void __attribute__((overloadable))
82 rsClearObject(rs_type *dst);
Jason Sams9df3b2b2011-08-08 14:31:25 -070083/**
84 * \overload
85 */
Jason Samsc0936852010-08-16 12:41:48 -070086extern void __attribute__((overloadable))
87 rsClearObject(rs_allocation *dst);
Jason Sams9df3b2b2011-08-08 14:31:25 -070088/**
89 * \overload
90 */
Jason Samsc0936852010-08-16 12:41:48 -070091extern void __attribute__((overloadable))
92 rsClearObject(rs_sampler *dst);
Jason Sams9df3b2b2011-08-08 14:31:25 -070093/**
94 * \overload
95 */
Jason Samsc0936852010-08-16 12:41:48 -070096extern void __attribute__((overloadable))
97 rsClearObject(rs_script *dst);
Jason Sams9df3b2b2011-08-08 14:31:25 -070098/**
99 * \overload
100 */
Jason Samsc0936852010-08-16 12:41:48 -0700101extern void __attribute__((overloadable))
102 rsClearObject(rs_mesh *dst);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700103/**
104 * \overload
105 */
Jason Samsc0936852010-08-16 12:41:48 -0700106extern void __attribute__((overloadable))
107 rsClearObject(rs_program_fragment *dst);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700108/**
109 * \overload
110 */
Jason Samsc0936852010-08-16 12:41:48 -0700111extern void __attribute__((overloadable))
112 rsClearObject(rs_program_vertex *dst);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700113/**
114 * \overload
115 */
Jason Samsc0936852010-08-16 12:41:48 -0700116extern void __attribute__((overloadable))
117 rsClearObject(rs_program_raster *dst);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700118/**
119 * \overload
120 */
Jason Samsc0936852010-08-16 12:41:48 -0700121extern void __attribute__((overloadable))
122 rsClearObject(rs_program_store *dst);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700123/**
124 * \overload
125 */
Jason Samsc0936852010-08-16 12:41:48 -0700126extern void __attribute__((overloadable))
127 rsClearObject(rs_font *dst);
128
Jason Sams09aeb8a2011-01-28 15:49:07 -0800129/**
Jason Sams9df3b2b2011-08-08 14:31:25 -0700130 * \overload
131 */
132extern bool __attribute__((overloadable))
133 rsIsObject(rs_element);
134/**
135 * \overload
136 */
137extern bool __attribute__((overloadable))
138 rsIsObject(rs_type);
139/**
140 * \overload
141 */
142extern bool __attribute__((overloadable))
143 rsIsObject(rs_allocation);
144/**
Jason Sams09aeb8a2011-01-28 15:49:07 -0800145 * Tests if the object is valid. Returns true if the object is valid, false if
146 * it is NULL.
147 *
148 * @return bool
149 */
Jason Sams9df3b2b2011-08-08 14:31:25 -0700150
Jason Samsc0936852010-08-16 12:41:48 -0700151extern bool __attribute__((overloadable))
152 rsIsObject(rs_sampler);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700153/**
154 * \overload
155 */
Jason Samsc0936852010-08-16 12:41:48 -0700156extern bool __attribute__((overloadable))
157 rsIsObject(rs_script);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700158/**
159 * \overload
160 */
Jason Samsc0936852010-08-16 12:41:48 -0700161extern bool __attribute__((overloadable))
162 rsIsObject(rs_mesh);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700163/**
164 * \overload
165 */
Jason Samsc0936852010-08-16 12:41:48 -0700166extern bool __attribute__((overloadable))
167 rsIsObject(rs_program_fragment);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700168/**
169 * \overload
170 */
Jason Samsc0936852010-08-16 12:41:48 -0700171extern bool __attribute__((overloadable))
172 rsIsObject(rs_program_vertex);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700173/**
174 * \overload
175 */
Jason Samsc0936852010-08-16 12:41:48 -0700176extern bool __attribute__((overloadable))
177 rsIsObject(rs_program_raster);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700178/**
179 * \overload
180 */
Jason Samsc0936852010-08-16 12:41:48 -0700181extern bool __attribute__((overloadable))
182 rsIsObject(rs_program_store);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700183/**
184 * \overload
185 */
Jason Samsc0936852010-08-16 12:41:48 -0700186extern bool __attribute__((overloadable))
187 rsIsObject(rs_font);
188
189
Jason Sams09aeb8a2011-01-28 15:49:07 -0800190/**
191 * Returns the Allocation for a given pointer. The pointer should point within
192 * a valid allocation. The results are undefined if the pointer is not from a
193 * valid allocation.
194 */
Jason Samsef5867a2010-07-28 11:17:53 -0700195extern rs_allocation __attribute__((overloadable))
196 rsGetAllocation(const void *);
Jason Sams73495472010-07-29 17:31:14 -0700197
Jason Sams09aeb8a2011-01-28 15:49:07 -0800198/**
Jason Sams09aeb8a2011-01-28 15:49:07 -0800199 * Query the dimension of an allocation.
200 *
201 * @return uint32_t The X dimension of the allocation.
202 */
Jason Samsef5867a2010-07-28 11:17:53 -0700203extern uint32_t __attribute__((overloadable))
204 rsAllocationGetDimX(rs_allocation);
Jason Sams09aeb8a2011-01-28 15:49:07 -0800205
206/**
207 * Query the dimension of an allocation.
208 *
209 * @return uint32_t The Y dimension of the allocation.
210 */
Jason Samsef5867a2010-07-28 11:17:53 -0700211extern uint32_t __attribute__((overloadable))
212 rsAllocationGetDimY(rs_allocation);
Jason Sams09aeb8a2011-01-28 15:49:07 -0800213
214/**
215 * Query the dimension of an allocation.
216 *
217 * @return uint32_t The Z dimension of the allocation.
218 */
Jason Samsef5867a2010-07-28 11:17:53 -0700219extern uint32_t __attribute__((overloadable))
220 rsAllocationGetDimZ(rs_allocation);
Jason Sams09aeb8a2011-01-28 15:49:07 -0800221
222/**
223 * Query an allocation for the presence of more than one LOD.
224 *
225 * @return uint32_t Returns 1 if more than one LOD is present, 0 otherwise.
226 */
Jason Samsef5867a2010-07-28 11:17:53 -0700227extern uint32_t __attribute__((overloadable))
228 rsAllocationGetDimLOD(rs_allocation);
Jason Sams09aeb8a2011-01-28 15:49:07 -0800229
230/**
231 * Query an allocation for the presence of more than one face.
232 *
233 * @return uint32_t Returns 1 if more than one face is present, 0 otherwise.
234 */
Jason Samsef5867a2010-07-28 11:17:53 -0700235extern uint32_t __attribute__((overloadable))
236 rsAllocationGetDimFaces(rs_allocation);
Jason Sams22fa3712010-05-19 17:22:57 -0700237
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700238/**
239 * Copy part of an allocation from another allocation.
240 *
241 * @param dstAlloc Allocation to copy data into.
242 * @param dstOff The offset of the first element to be copied in
243 * the destination allocation.
244 * @param dstMip Mip level in the destination allocation.
245 * @param count The number of elements to be copied.
246 * @param srcAlloc The source data allocation.
247 * @param srcOff The offset of the first element in data to be
248 * copied in the source allocation.
249 * @param srcMip Mip level in the source allocation.
250 */
251extern void __attribute__((overloadable))
252 rsAllocationCopy1DRange(rs_allocation dstAlloc,
253 uint32_t dstOff, uint32_t dstMip,
254 uint32_t count,
255 rs_allocation srcAlloc,
256 uint32_t srcOff, uint32_t srcMip);
257
258/**
259 * Copy a rectangular region into the allocation from another
260 * allocation.
261 *
262 * @param dstAlloc allocation to copy data into.
263 * @param dstXoff X offset of the region to update in the
264 * destination allocation.
265 * @param dstYoff Y offset of the region to update in the
266 * destination allocation.
267 * @param dstMip Mip level in the destination allocation.
268 * @param dstFace Cubemap face of the destination allocation,
269 * ignored for allocations that aren't cubemaps.
270 * @param width Width of the incoming region to update.
271 * @param height Height of the incoming region to update.
272 * @param srcAlloc The source data allocation.
273 * @param srcXoff X offset in data of the source allocation.
274 * @param srcYoff Y offset in data of the source allocation.
275 * @param srcMip Mip level in the source allocation.
276 * @param srcFace Cubemap face of the source allocation,
277 * ignored for allocations that aren't cubemaps.
278 */
279extern void __attribute__((overloadable))
280 rsAllocationCopy2DRange(rs_allocation dstAlloc,
281 uint32_t dstXoff, uint32_t dstYoff,
282 uint32_t dstMip,
283 rs_allocation_cubemap_face dstFace,
284 uint32_t width, uint32_t height,
285 rs_allocation srcAlloc,
286 uint32_t srcXoff, uint32_t srcYoff,
287 uint32_t srcMip,
288 rs_allocation_cubemap_face srcFace);
289
Jason Sams9df3b2b2011-08-08 14:31:25 -0700290
291/**
292 * Extract a single element from an allocation.
293 */
Jason Sams7bf29dd2010-07-19 15:38:19 -0700294extern const void * __attribute__((overloadable))
295 rsGetElementAt(rs_allocation, uint32_t x);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700296/**
297 * \overload
298 */
Jason Sams7bf29dd2010-07-19 15:38:19 -0700299extern const void * __attribute__((overloadable))
300 rsGetElementAt(rs_allocation, uint32_t x, uint32_t y);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700301/**
302 * \overload
303 */
Jason Sams7bf29dd2010-07-19 15:38:19 -0700304extern const void * __attribute__((overloadable))
305 rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z);
Jason Sams22fa3712010-05-19 17:22:57 -0700306
Jason Sams9df3b2b2011-08-08 14:31:25 -0700307/**
308 * Return a random value between 0 (or min_value) and max_malue.
309 */
Jason Sams73495472010-07-29 17:31:14 -0700310extern int __attribute__((overloadable))
311 rsRand(int max_value);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700312/**
313 * \overload
314 */
Jason Sams73495472010-07-29 17:31:14 -0700315extern int __attribute__((overloadable))
316 rsRand(int min_value, int max_value);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700317/**
318 * \overload
319 */
Jason Sams73495472010-07-29 17:31:14 -0700320extern float __attribute__((overloadable))
321 rsRand(float max_value);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700322/**
323 * \overload
324 */
Jason Sams73495472010-07-29 17:31:14 -0700325extern float __attribute__((overloadable))
326 rsRand(float min_value, float max_value);
Jason Sams22fa3712010-05-19 17:22:57 -0700327
Jason Sams9df3b2b2011-08-08 14:31:25 -0700328/**
329 * Returns the fractional part of a float
330 */
Jason Sams73495472010-07-29 17:31:14 -0700331extern float __attribute__((overloadable))
332 rsFrac(float);
Jason Sams22fa3712010-05-19 17:22:57 -0700333
Jason Sams9df3b2b2011-08-08 14:31:25 -0700334/**
335 * Send a message back to the client. Will not block and returns true
336 * if the message was sendable and false if the fifo was full.
337 * A message ID is required. Data payload is optional.
338 */
Jason Sams73495472010-07-29 17:31:14 -0700339extern bool __attribute__((overloadable))
340 rsSendToClient(int cmdID);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700341/**
342 * \overload
343 */
Jason Sams73495472010-07-29 17:31:14 -0700344extern bool __attribute__((overloadable))
345 rsSendToClient(int cmdID, const void *data, uint len);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700346/**
347 * Send a message back to the client, blocking until the message is queued.
348 * A message ID is required. Data payload is optional.
349 */
Jason Sams73495472010-07-29 17:31:14 -0700350extern void __attribute__((overloadable))
351 rsSendToClientBlocking(int cmdID);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700352/**
353 * \overload
354 */
Jason Sams73495472010-07-29 17:31:14 -0700355extern void __attribute__((overloadable))
356 rsSendToClientBlocking(int cmdID, const void *data, uint len);
Jason Sams22fa3712010-05-19 17:22:57 -0700357
Jason Samsdd663fa2010-08-11 13:26:28 -0700358
Jason Sams9df3b2b2011-08-08 14:31:25 -0700359/**
360 * Launch order hint for rsForEach calls. This provides a hint to the system to
361 * determine in which order the root function of the target is called with each
362 * cell of the allocation.
363 *
364 * This is a hint and implementations may not obey the order.
365 */
Jason Samsdd663fa2010-08-11 13:26:28 -0700366enum rs_for_each_strategy {
367 RS_FOR_EACH_STRATEGY_SERIAL,
368 RS_FOR_EACH_STRATEGY_DONT_CARE,
369 RS_FOR_EACH_STRATEGY_DST_LINEAR,
370 RS_FOR_EACH_STRATEGY_TILE_SMALL,
371 RS_FOR_EACH_STRATEGY_TILE_MEDIUM,
372 RS_FOR_EACH_STRATEGY_TILE_LARGE
373};
374
Jason Sams9df3b2b2011-08-08 14:31:25 -0700375
376/**
377 * Structure to provide extra information to a rsForEach call. Primarly used to
378 * restrict the call to a subset of cells in the allocation.
379 */
Jason Samsace3e012010-07-15 17:11:13 -0700380typedef struct rs_script_call {
Jason Samsdd663fa2010-08-11 13:26:28 -0700381 enum rs_for_each_strategy strategy;
Jason Sams479e2922010-07-09 15:34:32 -0700382 uint32_t xStart;
383 uint32_t xEnd;
384 uint32_t yStart;
385 uint32_t yEnd;
386 uint32_t zStart;
387 uint32_t zEnd;
388 uint32_t arrayStart;
389 uint32_t arrayEnd;
Jason Samsace3e012010-07-15 17:11:13 -0700390} rs_script_call_t;
Jason Sams479e2922010-07-09 15:34:32 -0700391
Jason Sams9df3b2b2011-08-08 14:31:25 -0700392/**
393 * Make a script to script call to launch work. One of the input or output is
394 * required to be a valid object. The input and output must be of the same
395 * dimensions.
396 * API 10-13
397 *
398 * @param script The target script to call
399 * @param input The allocation to source data from
400 * @param output the allocation to write date into
401 * @param usrData The user definied params to pass to the root script. May be
402 * NULL.
403 * @param sc Extra control infomation used to select a sub-region of the
404 * allocation to be processed or suggest a walking strategy. May be
405 * NULL.
406 *
407 * */
Jason Samseb0dfed2011-07-27 14:10:53 -0700408#if !defined(RS_VERSION) || (RS_VERSION < 14)
409extern void __attribute__((overloadable))
Jason Sams9df3b2b2011-08-08 14:31:25 -0700410 rsForEach(rs_script script script, rs_allocation input,
Jason Samseb0dfed2011-07-27 14:10:53 -0700411 rs_allocation output, const void * usrData,
Jason Sams9df3b2b2011-08-08 14:31:25 -0700412 const rs_script_call_t *sc);
413/**
414 * \overload
415 */
Jason Samseb0dfed2011-07-27 14:10:53 -0700416extern void __attribute__((overloadable))
417 rsForEach(rs_script script, rs_allocation input,
418 rs_allocation output, const void * usrData);
419#else
Jason Samsace3e012010-07-15 17:11:13 -0700420
Jason Sams9df3b2b2011-08-08 14:31:25 -0700421/**
422 * Make a script to script call to launch work. One of the input or output is
423 * required to be a valid object. The input and output must be of the same
424 * dimensions.
425 * API 14+
426 *
427 * @param script The target script to call
428 * @param input The allocation to source data from
429 * @param output the allocation to write date into
430 * @param usrData The user definied params to pass to the root script. May be
431 * NULL.
432 * @param usrDataLen The size of the userData structure. This will be used to
433 * perform a shallow copy of the data if necessary.
434 * @param sc Extra control infomation used to select a sub-region of the
435 * allocation to be processed or suggest a walking strategy. May be
436 * NULL.
437 *
438 */
Jason Samsc500e742011-07-25 12:58:37 -0700439extern void __attribute__((overloadable))
440 rsForEach(rs_script script, rs_allocation input, rs_allocation output,
441 const void * usrData, size_t usrDataLen, const rs_script_call_t *);
Jason Sams9df3b2b2011-08-08 14:31:25 -0700442/**
443 * \overload
444 */
445extern void __attribute__((overloadable))
446 rsForEach(rs_script script, rs_allocation input, rs_allocation output,
447 const void * usrData, size_t usrDataLen);
448/**
449 * \overload
450 */
451extern void __attribute__((overloadable))
452 rsForEach(rs_script script, rs_allocation input, rs_allocation output);
Jason Samsc500e742011-07-25 12:58:37 -0700453#endif
Jason Samsc61346b2010-05-28 18:23:22 -0700454
Jason Samse1eb6152011-06-21 16:42:30 -0700455
456/**
457 * Atomic add one to the value at addr.
458 * Equal to rsAtomicAdd(addr, 1)
459 *
460 * @param addr Address of value to increment
461 *
462 * @return old value
463 */
464extern int32_t __attribute__((overloadable))
465 rsAtomicInc(volatile int32_t* addr);
466/**
467 * Atomic add one to the value at addr.
468 * Equal to rsAtomicAdd(addr, 1)
469 *
470 * @param addr Address of value to increment
471 *
472 * @return old value
473 */
474extern uint32_t __attribute__((overloadable))
475 rsAtomicInc(volatile uint32_t* addr);
476
477/**
478 * Atomic subtract one from the value at addr. Equal to rsAtomicSub(addr, 1)
479 *
480 * @param addr Address of value to decrement
481 *
482 * @return old value
483 */
484extern int32_t __attribute__((overloadable))
485 rsAtomicDec(volatile int32_t* addr);
486/**
487 * Atomic subtract one from the value at addr. Equal to rsAtomicSub(addr, 1)
488 *
489 * @param addr Address of value to decrement
490 *
491 * @return old value
492 */
493extern uint32_t __attribute__((overloadable))
494 rsAtomicDec(volatile uint32_t* addr);
495
496/**
497 * Atomic add a value to the value at addr. addr[0] += value
498 *
499 * @param addr Address of value to modify
500 * @param value Amount to add to the value at addr
501 *
502 * @return old value
503 */
504extern int32_t __attribute__((overloadable))
505 rsAtomicAdd(volatile int32_t* addr, int32_t value);
506/**
507 * Atomic add a value to the value at addr. addr[0] += value
508 *
509 * @param addr Address of value to modify
510 * @param value Amount to add to the value at addr
511 *
512 * @return old value
513 */
514extern uint32_t __attribute__((overloadable))
515 rsAtomicAdd(volatile uint32_t* addr, uint32_t value);
516
517/**
518 * Atomic Subtract a value from the value at addr. addr[0] -= value
519 *
520 * @param addr Address of value to modify
521 * @param value Amount to subtract from the value at addr
522 *
523 * @return old value
524 */
525extern int32_t __attribute__((overloadable))
526 rsAtomicSub(volatile int32_t* addr, int32_t value);
527/**
528 * Atomic Subtract a value from the value at addr. addr[0] -= value
529 *
530 * @param addr Address of value to modify
531 * @param value Amount to subtract from the value at addr
532 *
533 * @return old value
534 */
535extern uint32_t __attribute__((overloadable))
536 rsAtomicSub(volatile uint32_t* addr, uint32_t value);
537
538/**
539 * Atomic Bitwise and a value from the value at addr. addr[0] &= value
540 *
541 * @param addr Address of value to modify
542 * @param value Amount to and with the value at addr
543 *
544 * @return old value
545 */
546extern int32_t __attribute__((overloadable))
547 rsAtomicAnd(volatile int32_t* addr, int32_t value);
548/**
549 * Atomic Bitwise and a value from the value at addr. addr[0] &= value
550 *
551 * @param addr Address of value to modify
552 * @param value Amount to and with the value at addr
553 *
554 * @return old value
555 */
556extern uint32_t __attribute__((overloadable))
557 rsAtomicAnd(volatile uint32_t* addr, uint32_t value);
558
559/**
560 * Atomic Bitwise or a value from the value at addr. addr[0] |= value
561 *
562 * @param addr Address of value to modify
563 * @param value Amount to or with the value at addr
564 *
565 * @return old value
566 */
567extern int32_t __attribute__((overloadable))
568 rsAtomicOr(volatile int32_t* addr, int32_t value);
569/**
570 * Atomic Bitwise or a value from the value at addr. addr[0] |= value
571 *
572 * @param addr Address of value to modify
573 * @param value Amount to or with the value at addr
574 *
575 * @return old value
576 */
577extern uint32_t __attribute__((overloadable))
578 rsAtomicOr(volatile uint32_t* addr, uint32_t value);
579
580/**
581 * Atomic Bitwise xor a value from the value at addr. addr[0] ^= value
582 *
583 * @param addr Address of value to modify
584 * @param value Amount to xor with the value at addr
585 *
586 * @return old value
587 */
588extern uint32_t __attribute__((overloadable))
589 rsAtomicXor(volatile uint32_t* addr, uint32_t value);
590/**
591 * Atomic Bitwise xor a value from the value at addr. addr[0] ^= value
592 *
593 * @param addr Address of value to modify
594 * @param value Amount to xor with the value at addr
595 *
596 * @return old value
597 */
598extern int32_t __attribute__((overloadable))
599 rsAtomicXor(volatile int32_t* addr, int32_t value);
600
601/**
602 * Atomic Set the value at addr to the min of addr and value
603 * addr[0] = rsMin(addr[0], value)
604 *
605 * @param addr Address of value to modify
606 * @param value comparison value
607 *
608 * @return old value
609 */
610extern uint32_t __attribute__((overloadable))
611 rsAtomicMin(volatile uint32_t* addr, uint32_t value);
612/**
613 * Atomic Set the value at addr to the min of addr and value
614 * addr[0] = rsMin(addr[0], value)
615 *
616 * @param addr Address of value to modify
617 * @param value comparison value
618 *
619 * @return old value
620 */
621extern int32_t __attribute__((overloadable))
622 rsAtomicMin(volatile int32_t* addr, int32_t value);
623
624/**
625 * Atomic Set the value at addr to the max of addr and value
626 * addr[0] = rsMax(addr[0], value)
627 *
628 * @param addr Address of value to modify
629 * @param value comparison value
630 *
631 * @return old value
632 */
633extern uint32_t __attribute__((overloadable))
634 rsAtomicMax(volatile uint32_t* addr, uint32_t value);
635/**
636 * Atomic Set the value at addr to the max of addr and value
637 * addr[0] = rsMin(addr[0], value)
638 *
639 * @param addr Address of value to modify
640 * @param value comparison value
641 *
642 * @return old value
643 */
644extern int32_t __attribute__((overloadable))
645 rsAtomicMax(volatile int32_t* addr, int32_t value);
646
647/**
648 * Compare-and-set operation with a full memory barrier.
649 *
650 * If the value at addr matches compareValue then newValue is written.
651 *
652 * @param addr The address to compare and replace if the compare passes.
653 * @param compareValue The value to test addr[0] against.
654 * @param newValue The value to write if the test passes.
655 *
656 * @return old value
657 */
658extern int32_t __attribute__((overloadable))
659 rsAtomicCas(volatile int32_t* addr, int32_t compareValue, int32_t newValue);
660
661/**
662 * Compare-and-set operation with a full memory barrier.
663 *
664 * If the value at addr matches compareValue then newValue is written.
665 *
666 * @param addr The address to compare and replace if the compare passes.
667 * @param compareValue The value to test addr[0] against.
668 * @param newValue The value to write if the test passes.
669 *
670 * @return old value
671 */
672extern uint32_t __attribute__((overloadable))
673 rsAtomicCas(volatile uint32_t* addr, int32_t compareValue, int32_t newValue);
674
675
Jason Samsc4cdf452010-07-07 11:55:51 -0700676#endif