Mercurial > sdl-ios-xcode
comparison src/atomic/linux/SDL_atomic.c @ 3216:48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
author | Bob Pendleton <bob@pendleton.com> |
---|---|
date | Thu, 09 Jul 2009 21:31:27 +0000 |
parents | 759032c318d8 |
children | 72b542f34739 |
comparison
equal
deleted
inserted
replaced
3215:b425c3e2b796 | 3216:48a80f2a7ff2 |
---|---|
135 #endif | 135 #endif |
136 | 136 |
137 /* 8 bit atomic operations */ | 137 /* 8 bit atomic operations */ |
138 | 138 |
139 Uint8 | 139 Uint8 |
140 SDL_AtomicExchange8(Uint8 * ptr, Uint8 value) | 140 SDL_AtomicExchange8(volatile Uint8 * ptr, Uint8 value) |
141 { | 141 { |
142 #ifdef nativeExchange8 | 142 #ifdef nativeExchange8 |
143 return nativeExchange8(ptr, value); | 143 return nativeExchange8(ptr, value); |
144 #else | 144 #else |
145 Uint8 tmp = 0; | 145 Uint8 tmp = 0; |
152 return tmp; | 152 return tmp; |
153 #endif | 153 #endif |
154 } | 154 } |
155 | 155 |
156 SDL_bool | 156 SDL_bool |
157 SDL_AtomicCompareThenSet8(Uint8 * ptr, Uint8 oldvalue, Uint8 newvalue) | 157 SDL_AtomicCompareThenSet8(volatile Uint8 * ptr, Uint8 oldvalue, Uint8 newvalue) |
158 { | 158 { |
159 #ifdef nativeCompareThenSet8 | 159 #ifdef nativeCompareThenSet8 |
160 return (SDL_bool)nativeCompareThenSet8(ptr, oldvalue, newvalue); | 160 return (SDL_bool)nativeCompareThenSet8(ptr, oldvalue, newvalue); |
161 #else | 161 #else |
162 SDL_bool result = SDL_FALSE; | 162 SDL_bool result = SDL_FALSE; |
172 return result; | 172 return result; |
173 #endif | 173 #endif |
174 } | 174 } |
175 | 175 |
176 SDL_bool | 176 SDL_bool |
177 SDL_AtomicTestThenSet8(Uint8 * ptr) | 177 SDL_AtomicTestThenSet8(volatile Uint8 * ptr) |
178 { | 178 { |
179 #ifdef nativeTestThenSet8 | 179 #ifdef nativeTestThenSet8 |
180 return (SDL_bool)nativeTestThenSet8(ptr); | 180 return (SDL_bool)nativeTestThenSet8(ptr); |
181 #else | 181 #else |
182 SDL_bool result = SDL_FALSE; | 182 SDL_bool result = SDL_FALSE; |
192 return result; | 192 return result; |
193 #endif | 193 #endif |
194 } | 194 } |
195 | 195 |
196 void | 196 void |
197 SDL_AtomicClear8(Uint8 * ptr) | 197 SDL_AtomicClear8(volatile Uint8 * ptr) |
198 { | 198 { |
199 #ifdef nativeClear8 | 199 #ifdef nativeClear8 |
200 nativeClear8(ptr); | 200 nativeClear8(ptr); |
201 #else | 201 #else |
202 privateWaitLock(); | 202 privateWaitLock(); |
206 return; | 206 return; |
207 #endif | 207 #endif |
208 } | 208 } |
209 | 209 |
210 Uint8 | 210 Uint8 |
211 SDL_AtomicFetchThenIncrement8(Uint8 * ptr) | 211 SDL_AtomicFetchThenIncrement8(volatile Uint8 * ptr) |
212 { | 212 { |
213 #ifdef nativeFetchThenIncrement8 | 213 #ifdef nativeFetchThenIncrement8 |
214 return nativeFetchThenIncrement8(ptr); | 214 return nativeFetchThenIncrement8(ptr); |
215 #else | 215 #else |
216 Uint8 tmp = 0; | 216 Uint8 tmp = 0; |
223 return tmp; | 223 return tmp; |
224 #endif | 224 #endif |
225 } | 225 } |
226 | 226 |
227 Uint8 | 227 Uint8 |
228 SDL_AtomicFetchThenDecrement8(Uint8 * ptr) | 228 SDL_AtomicFetchThenDecrement8(volatile Uint8 * ptr) |
229 { | 229 { |
230 #ifdef nativeFetchThenDecrement8 | 230 #ifdef nativeFetchThenDecrement8 |
231 return nativeFetchThenDecrement8(ptr); | 231 return nativeFetchThenDecrement8(ptr); |
232 #else | 232 #else |
233 Uint8 tmp = 0; | 233 Uint8 tmp = 0; |
240 return tmp; | 240 return tmp; |
241 #endif | 241 #endif |
242 } | 242 } |
243 | 243 |
244 Uint8 | 244 Uint8 |
245 SDL_AtomicFetchThenAdd8(Uint8 * ptr, Uint8 value) | 245 SDL_AtomicFetchThenAdd8(volatile Uint8 * ptr, Uint8 value) |
246 { | 246 { |
247 #ifdef nativeFetchThenAdd8 | 247 #ifdef nativeFetchThenAdd8 |
248 return nativeFetchThenAdd8(ptr, value); | 248 return nativeFetchThenAdd8(ptr, value); |
249 #else | 249 #else |
250 Uint8 tmp = 0; | 250 Uint8 tmp = 0; |
257 return tmp; | 257 return tmp; |
258 #endif | 258 #endif |
259 } | 259 } |
260 | 260 |
261 Uint8 | 261 Uint8 |
262 SDL_AtomicFetchThenSubtract8(Uint8 * ptr, Uint8 value) | 262 SDL_AtomicFetchThenSubtract8(volatile Uint8 * ptr, Uint8 value) |
263 { | 263 { |
264 #ifdef nativeFetchThenSubtract8 | 264 #ifdef nativeFetchThenSubtract8 |
265 return nativeFetchThenSubtract8(ptr, value); | 265 return nativeFetchThenSubtract8(ptr, value); |
266 #else | 266 #else |
267 Uint8 tmp = 0; | 267 Uint8 tmp = 0; |
274 return tmp; | 274 return tmp; |
275 #endif | 275 #endif |
276 } | 276 } |
277 | 277 |
278 Uint8 | 278 Uint8 |
279 SDL_AtomicIncrementThenFetch8(Uint8 * ptr) | 279 SDL_AtomicIncrementThenFetch8(volatile Uint8 * ptr) |
280 { | 280 { |
281 #ifdef nativeIncrementThenFetch8 | 281 #ifdef nativeIncrementThenFetch8 |
282 return nativeIncrementThenFetch8(ptr); | 282 return nativeIncrementThenFetch8(ptr); |
283 #else | 283 #else |
284 Uint8 tmp = 0; | 284 Uint8 tmp = 0; |
291 return tmp; | 291 return tmp; |
292 #endif | 292 #endif |
293 } | 293 } |
294 | 294 |
295 Uint8 | 295 Uint8 |
296 SDL_AtomicDecrementThenFetch8(Uint8 * ptr) | 296 SDL_AtomicDecrementThenFetch8(volatile Uint8 * ptr) |
297 { | 297 { |
298 #ifdef nativeDecrementThenFetch8 | 298 #ifdef nativeDecrementThenFetch8 |
299 return nativeDecrementThenFetch8(ptr); | 299 return nativeDecrementThenFetch8(ptr); |
300 #else | 300 #else |
301 Uint8 tmp = 0; | 301 Uint8 tmp = 0; |
308 return tmp; | 308 return tmp; |
309 #endif | 309 #endif |
310 } | 310 } |
311 | 311 |
312 Uint8 | 312 Uint8 |
313 SDL_AtomicAddThenFetch8(Uint8 * ptr, Uint8 value) | 313 SDL_AtomicAddThenFetch8(volatile Uint8 * ptr, Uint8 value) |
314 { | 314 { |
315 #ifdef nativeAddThenFetch8 | 315 #ifdef nativeAddThenFetch8 |
316 return nativeAddThenFetch8(ptr, value); | 316 return nativeAddThenFetch8(ptr, value); |
317 #else | 317 #else |
318 Uint8 tmp = 0; | 318 Uint8 tmp = 0; |
325 return tmp; | 325 return tmp; |
326 #endif | 326 #endif |
327 } | 327 } |
328 | 328 |
329 Uint8 | 329 Uint8 |
330 SDL_AtomicSubtractThenFetch8(Uint8 * ptr, Uint8 value) | 330 SDL_AtomicSubtractThenFetch8(volatile Uint8 * ptr, Uint8 value) |
331 { | 331 { |
332 #ifdef nativeSubtractThenFetch8 | 332 #ifdef nativeSubtractThenFetch8 |
333 return nativeSubtractThenFetch8(ptr, value); | 333 return nativeSubtractThenFetch8(ptr, value); |
334 #else | 334 #else |
335 Uint8 tmp = 0; | 335 Uint8 tmp = 0; |
344 } | 344 } |
345 | 345 |
346 /* 16 bit atomic operations */ | 346 /* 16 bit atomic operations */ |
347 | 347 |
348 Uint16 | 348 Uint16 |
349 SDL_AtomicExchange16(Uint16 * ptr, Uint16 value) | 349 SDL_AtomicExchange16(volatile Uint16 * ptr, Uint16 value) |
350 { | 350 { |
351 #ifdef nativeExchange16 | 351 #ifdef nativeExchange16 |
352 return nativeExchange16(ptr, value); | 352 return nativeExchange16(ptr, value); |
353 #else | 353 #else |
354 Uint16 tmp = 0; | 354 Uint16 tmp = 0; |
361 return tmp; | 361 return tmp; |
362 #endif | 362 #endif |
363 } | 363 } |
364 | 364 |
365 SDL_bool | 365 SDL_bool |
366 SDL_AtomicCompareThenSet16(Uint16 * ptr, Uint16 oldvalue, Uint16 newvalue) | 366 SDL_AtomicCompareThenSet16(volatile Uint16 * ptr, Uint16 oldvalue, Uint16 newvalue) |
367 { | 367 { |
368 #ifdef nativeCompareThenSet16 | 368 #ifdef nativeCompareThenSet16 |
369 return (SDL_bool)nativeCompareThenSet16(ptr, oldvalue, newvalue); | 369 return (SDL_bool)nativeCompareThenSet16(ptr, oldvalue, newvalue); |
370 #else | 370 #else |
371 SDL_bool result = SDL_FALSE; | 371 SDL_bool result = SDL_FALSE; |
381 return result; | 381 return result; |
382 #endif | 382 #endif |
383 } | 383 } |
384 | 384 |
385 SDL_bool | 385 SDL_bool |
386 SDL_AtomicTestThenSet16(Uint16 * ptr) | 386 SDL_AtomicTestThenSet16(volatile Uint16 * ptr) |
387 { | 387 { |
388 #ifdef nativeTestThenSet16 | 388 #ifdef nativeTestThenSet16 |
389 return (SDL_bool)nativeTestThenSet16(ptr); | 389 return (SDL_bool)nativeTestThenSet16(ptr); |
390 #else | 390 #else |
391 SDL_bool result = SDL_FALSE; | 391 SDL_bool result = SDL_FALSE; |
401 return result; | 401 return result; |
402 #endif | 402 #endif |
403 } | 403 } |
404 | 404 |
405 void | 405 void |
406 SDL_AtomicClear16(Uint16 * ptr) | 406 SDL_AtomicClear16(volatile Uint16 * ptr) |
407 { | 407 { |
408 #ifdef nativeClear16 | 408 #ifdef nativeClear16 |
409 nativeClear16(ptr); | 409 nativeClear16(ptr); |
410 #else | 410 #else |
411 privateWaitLock(); | 411 privateWaitLock(); |
415 return; | 415 return; |
416 #endif | 416 #endif |
417 } | 417 } |
418 | 418 |
419 Uint16 | 419 Uint16 |
420 SDL_AtomicFetchThenIncrement16(Uint16 * ptr) | 420 SDL_AtomicFetchThenIncrement16(volatile Uint16 * ptr) |
421 { | 421 { |
422 #ifdef nativeFetchThenIncrement16 | 422 #ifdef nativeFetchThenIncrement16 |
423 return nativeFetchThenIncrement16(ptr); | 423 return nativeFetchThenIncrement16(ptr); |
424 #else | 424 #else |
425 Uint16 tmp = 0; | 425 Uint16 tmp = 0; |
432 return tmp; | 432 return tmp; |
433 #endif | 433 #endif |
434 } | 434 } |
435 | 435 |
436 Uint16 | 436 Uint16 |
437 SDL_AtomicFetchThenDecrement16(Uint16 * ptr) | 437 SDL_AtomicFetchThenDecrement16(volatile Uint16 * ptr) |
438 { | 438 { |
439 #ifdef nativeFetchThenDecrement16 | 439 #ifdef nativeFetchThenDecrement16 |
440 return nativeFetchThenDecrement16(ptr); | 440 return nativeFetchThenDecrement16(ptr); |
441 #else | 441 #else |
442 Uint16 tmp = 0; | 442 Uint16 tmp = 0; |
449 return tmp; | 449 return tmp; |
450 #endif | 450 #endif |
451 } | 451 } |
452 | 452 |
453 Uint16 | 453 Uint16 |
454 SDL_AtomicFetchThenAdd16(Uint16 * ptr, Uint16 value) | 454 SDL_AtomicFetchThenAdd16(volatile Uint16 * ptr, Uint16 value) |
455 { | 455 { |
456 #ifdef nativeFetchThenAdd16 | 456 #ifdef nativeFetchThenAdd16 |
457 return nativeFetchThenAdd16(ptr, value); | 457 return nativeFetchThenAdd16(ptr, value); |
458 #else | 458 #else |
459 Uint16 tmp = 0; | 459 Uint16 tmp = 0; |
466 return tmp; | 466 return tmp; |
467 #endif | 467 #endif |
468 } | 468 } |
469 | 469 |
470 Uint16 | 470 Uint16 |
471 SDL_AtomicFetchThenSubtract16(Uint16 * ptr, Uint16 value) | 471 SDL_AtomicFetchThenSubtract16(volatile Uint16 * ptr, Uint16 value) |
472 { | 472 { |
473 #ifdef nativeFetchThenSubtract16 | 473 #ifdef nativeFetchThenSubtract16 |
474 return nativeFetchThenSubtract16(ptr, value); | 474 return nativeFetchThenSubtract16(ptr, value); |
475 #else | 475 #else |
476 Uint16 tmp = 0; | 476 Uint16 tmp = 0; |
483 return tmp; | 483 return tmp; |
484 #endif | 484 #endif |
485 } | 485 } |
486 | 486 |
487 Uint16 | 487 Uint16 |
488 SDL_AtomicIncrementThenFetch16(Uint16 * ptr) | 488 SDL_AtomicIncrementThenFetch16(volatile Uint16 * ptr) |
489 { | 489 { |
490 #ifdef nativeIncrementThenFetch16 | 490 #ifdef nativeIncrementThenFetch16 |
491 return nativeIncrementThenFetch16(ptr); | 491 return nativeIncrementThenFetch16(ptr); |
492 #else | 492 #else |
493 Uint16 tmp = 0; | 493 Uint16 tmp = 0; |
500 return tmp; | 500 return tmp; |
501 #endif | 501 #endif |
502 } | 502 } |
503 | 503 |
504 Uint16 | 504 Uint16 |
505 SDL_AtomicDecrementThenFetch16(Uint16 * ptr) | 505 SDL_AtomicDecrementThenFetch16(volatile Uint16 * ptr) |
506 { | 506 { |
507 #ifdef nativeDecrementThenFetch16 | 507 #ifdef nativeDecrementThenFetch16 |
508 return nativeDecrementThenFetch16(ptr); | 508 return nativeDecrementThenFetch16(ptr); |
509 #else | 509 #else |
510 Uint16 tmp = 0; | 510 Uint16 tmp = 0; |
517 return tmp; | 517 return tmp; |
518 #endif | 518 #endif |
519 } | 519 } |
520 | 520 |
521 Uint16 | 521 Uint16 |
522 SDL_AtomicAddThenFetch16(Uint16 * ptr, Uint16 value) | 522 SDL_AtomicAddThenFetch16(volatile Uint16 * ptr, Uint16 value) |
523 { | 523 { |
524 #ifdef nativeAddThenFetch16 | 524 #ifdef nativeAddThenFetch16 |
525 return nativeAddThenFetch16(ptr, value); | 525 return nativeAddThenFetch16(ptr, value); |
526 #else | 526 #else |
527 Uint16 tmp = 0; | 527 Uint16 tmp = 0; |
534 return tmp; | 534 return tmp; |
535 #endif | 535 #endif |
536 } | 536 } |
537 | 537 |
538 Uint16 | 538 Uint16 |
539 SDL_AtomicSubtractThenFetch16(Uint16 * ptr, Uint16 value) | 539 SDL_AtomicSubtractThenFetch16(volatile Uint16 * ptr, Uint16 value) |
540 { | 540 { |
541 #ifdef nativeSubtractThenFetch16 | 541 #ifdef nativeSubtractThenFetch16 |
542 return nativeSubtractThenFetch16(ptr, value); | 542 return nativeSubtractThenFetch16(ptr, value); |
543 #else | 543 #else |
544 Uint16 tmp = 0; | 544 Uint16 tmp = 0; |
553 } | 553 } |
554 | 554 |
555 /* 32 bit atomic operations */ | 555 /* 32 bit atomic operations */ |
556 | 556 |
557 Uint32 | 557 Uint32 |
558 SDL_AtomicExchange32(Uint32 * ptr, Uint32 value) | 558 SDL_AtomicExchange32(volatile Uint32 * ptr, Uint32 value) |
559 { | 559 { |
560 #ifdef nativeExchange32 | 560 #ifdef nativeExchange32 |
561 return nativeExchange32(ptr, value); | 561 return nativeExchange32(ptr, value); |
562 #else | 562 #else |
563 Uint32 tmp = 0; | 563 Uint32 tmp = 0; |
570 return tmp; | 570 return tmp; |
571 #endif | 571 #endif |
572 } | 572 } |
573 | 573 |
574 SDL_bool | 574 SDL_bool |
575 SDL_AtomicCompareThenSet32(Uint32 * ptr, Uint32 oldvalue, Uint32 newvalue) | 575 SDL_AtomicCompareThenSet32(volatile Uint32 * ptr, Uint32 oldvalue, Uint32 newvalue) |
576 { | 576 { |
577 #ifdef nativeCompareThenSet32 | 577 #ifdef nativeCompareThenSet32 |
578 return (SDL_bool)nativeCompareThenSet32(ptr, oldvalue, newvalue); | 578 return (SDL_bool)nativeCompareThenSet32(ptr, oldvalue, newvalue); |
579 #else | 579 #else |
580 SDL_bool result = SDL_FALSE; | 580 SDL_bool result = SDL_FALSE; |
590 return result; | 590 return result; |
591 #endif | 591 #endif |
592 } | 592 } |
593 | 593 |
594 SDL_bool | 594 SDL_bool |
595 SDL_AtomicTestThenSet32(Uint32 * ptr) | 595 SDL_AtomicTestThenSet32(volatile Uint32 * ptr) |
596 { | 596 { |
597 #ifdef nativeTestThenSet32 | 597 #ifdef nativeTestThenSet32 |
598 return (SDL_bool)nativeTestThenSet32(ptr); | 598 return (SDL_bool)nativeTestThenSet32(ptr); |
599 #else | 599 #else |
600 SDL_bool result = SDL_FALSE; | 600 SDL_bool result = SDL_FALSE; |
610 return result; | 610 return result; |
611 #endif | 611 #endif |
612 } | 612 } |
613 | 613 |
614 void | 614 void |
615 SDL_AtomicClear32(Uint32 * ptr) | 615 SDL_AtomicClear32(volatile Uint32 * ptr) |
616 { | 616 { |
617 #ifdef nativeClear32 | 617 #ifdef nativeClear32 |
618 nativeClear32(ptr); | 618 nativeClear32(ptr); |
619 #else | 619 #else |
620 privateWaitLock(); | 620 privateWaitLock(); |
624 return; | 624 return; |
625 #endif | 625 #endif |
626 } | 626 } |
627 | 627 |
628 Uint32 | 628 Uint32 |
629 SDL_AtomicFetchThenIncrement32(Uint32 * ptr) | 629 SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr) |
630 { | 630 { |
631 #ifdef nativeFetchThenIncrement32 | 631 #ifdef nativeFetchThenIncrement32 |
632 return nativeFetchThenIncrement32(ptr); | 632 return nativeFetchThenIncrement32(ptr); |
633 #else | 633 #else |
634 Uint32 tmp = 0; | 634 Uint32 tmp = 0; |
641 return tmp; | 641 return tmp; |
642 #endif | 642 #endif |
643 } | 643 } |
644 | 644 |
645 Uint32 | 645 Uint32 |
646 SDL_AtomicFetchThenDecrement32(Uint32 * ptr) | 646 SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr) |
647 { | 647 { |
648 #ifdef nativeFetchThenDecrement32 | 648 #ifdef nativeFetchThenDecrement32 |
649 return nativeFetchThenDecrement32(ptr); | 649 return nativeFetchThenDecrement32(ptr); |
650 #else | 650 #else |
651 Uint32 tmp = 0; | 651 Uint32 tmp = 0; |
658 return tmp; | 658 return tmp; |
659 #endif | 659 #endif |
660 } | 660 } |
661 | 661 |
662 Uint32 | 662 Uint32 |
663 SDL_AtomicFetchThenAdd32(Uint32 * ptr, Uint32 value) | 663 SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value) |
664 { | 664 { |
665 #ifdef nativeFetchThenAdd32 | 665 #ifdef nativeFetchThenAdd32 |
666 return nativeFetchThenAdd32(ptr, value); | 666 return nativeFetchThenAdd32(ptr, value); |
667 #else | 667 #else |
668 Uint32 tmp = 0; | 668 Uint32 tmp = 0; |
675 return tmp; | 675 return tmp; |
676 #endif | 676 #endif |
677 } | 677 } |
678 | 678 |
679 Uint32 | 679 Uint32 |
680 SDL_AtomicFetchThenSubtract32(Uint32 * ptr, Uint32 value) | 680 SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value) |
681 { | 681 { |
682 #ifdef nativeFetchThenSubtract32 | 682 #ifdef nativeFetchThenSubtract32 |
683 return nativeFetchThenSubtract32(ptr, value); | 683 return nativeFetchThenSubtract32(ptr, value); |
684 #else | 684 #else |
685 Uint32 tmp = 0; | 685 Uint32 tmp = 0; |
692 return tmp; | 692 return tmp; |
693 #endif | 693 #endif |
694 } | 694 } |
695 | 695 |
696 Uint32 | 696 Uint32 |
697 SDL_AtomicIncrementThenFetch32(Uint32 * ptr) | 697 SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr) |
698 { | 698 { |
699 #ifdef nativeIncrementThenFetch32 | 699 #ifdef nativeIncrementThenFetch32 |
700 return nativeIncrementThenFetch32(ptr); | 700 return nativeIncrementThenFetch32(ptr); |
701 #else | 701 #else |
702 Uint32 tmp = 0; | 702 Uint32 tmp = 0; |
709 return tmp; | 709 return tmp; |
710 #endif | 710 #endif |
711 } | 711 } |
712 | 712 |
713 Uint32 | 713 Uint32 |
714 SDL_AtomicDecrementThenFetch32(Uint32 * ptr) | 714 SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr) |
715 { | 715 { |
716 #ifdef nativeDecrementThenFetch32 | 716 #ifdef nativeDecrementThenFetch32 |
717 return nativeDecrementThenFetch32(ptr); | 717 return nativeDecrementThenFetch32(ptr); |
718 #else | 718 #else |
719 Uint32 tmp = 0; | 719 Uint32 tmp = 0; |
726 return tmp; | 726 return tmp; |
727 #endif | 727 #endif |
728 } | 728 } |
729 | 729 |
730 Uint32 | 730 Uint32 |
731 SDL_AtomicAddThenFetch32(Uint32 * ptr, Uint32 value) | 731 SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value) |
732 { | 732 { |
733 #ifdef nativeAddThenFetch32 | 733 #ifdef nativeAddThenFetch32 |
734 return nativeAddThenFetch32(ptr, value); | 734 return nativeAddThenFetch32(ptr, value); |
735 #else | 735 #else |
736 Uint32 tmp = 0; | 736 Uint32 tmp = 0; |
743 return tmp; | 743 return tmp; |
744 #endif | 744 #endif |
745 } | 745 } |
746 | 746 |
747 Uint32 | 747 Uint32 |
748 SDL_AtomicSubtractThenFetch32(Uint32 * ptr, Uint32 value) | 748 SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value) |
749 { | 749 { |
750 #ifdef nativeSubtractThenFetch32 | 750 #ifdef nativeSubtractThenFetch32 |
751 return nativeSubtractThenFetch32(ptr, value); | 751 return nativeSubtractThenFetch32(ptr, value); |
752 #else | 752 #else |
753 Uint32 tmp = 0; | 753 Uint32 tmp = 0; |
763 | 763 |
764 /* 64 bit atomic operations */ | 764 /* 64 bit atomic operations */ |
765 #ifdef SDL_HAS_64BIT_TYPE | 765 #ifdef SDL_HAS_64BIT_TYPE |
766 | 766 |
767 Uint64 | 767 Uint64 |
768 SDL_AtomicExchange64(Uint64 * ptr, Uint64 value) | 768 SDL_AtomicExchange64(volatile Uint64 * ptr, Uint64 value) |
769 { | 769 { |
770 #ifdef nativeExchange64 | 770 #ifdef nativeExchange64 |
771 return nativeExchange64(ptr, value); | 771 return nativeExchange64(ptr, value); |
772 #else | 772 #else |
773 Uint64 tmp = 0; | 773 Uint64 tmp = 0; |
780 return tmp; | 780 return tmp; |
781 #endif | 781 #endif |
782 } | 782 } |
783 | 783 |
784 SDL_bool | 784 SDL_bool |
785 SDL_AtomicCompareThenSet64(Uint64 * ptr, Uint64 oldvalue, Uint64 newvalue) | 785 SDL_AtomicCompareThenSet64(volatile Uint64 * ptr, Uint64 oldvalue, Uint64 newvalue) |
786 { | 786 { |
787 #ifdef nativeCompareThenSet64 | 787 #ifdef nativeCompareThenSet64 |
788 return (SDL_bool)nativeCompareThenSet64(ptr, oldvalue, newvalue); | 788 return (SDL_bool)nativeCompareThenSet64(ptr, oldvalue, newvalue); |
789 #else | 789 #else |
790 SDL_bool result = SDL_FALSE; | 790 SDL_bool result = SDL_FALSE; |
800 return result; | 800 return result; |
801 #endif | 801 #endif |
802 } | 802 } |
803 | 803 |
804 SDL_bool | 804 SDL_bool |
805 SDL_AtomicTestThenSet64(Uint64 * ptr) | 805 SDL_AtomicTestThenSet64(volatile Uint64 * ptr) |
806 { | 806 { |
807 #ifdef nativeTestThenSet64 | 807 #ifdef nativeTestThenSet64 |
808 return (SDL_bool)nativeTestThenSet64(ptr); | 808 return (SDL_bool)nativeTestThenSet64(ptr); |
809 #else | 809 #else |
810 SDL_bool result = SDL_FALSE; | 810 SDL_bool result = SDL_FALSE; |
820 return result; | 820 return result; |
821 #endif | 821 #endif |
822 } | 822 } |
823 | 823 |
824 void | 824 void |
825 SDL_AtomicClear64(Uint64 * ptr) | 825 SDL_AtomicClear64(volatile Uint64 * ptr) |
826 { | 826 { |
827 #ifdef nativeClear64 | 827 #ifdef nativeClear64 |
828 nativeClear64(ptr); | 828 nativeClear64(ptr); |
829 #else | 829 #else |
830 privateWaitLock(); | 830 privateWaitLock(); |
834 return; | 834 return; |
835 #endif | 835 #endif |
836 } | 836 } |
837 | 837 |
838 Uint64 | 838 Uint64 |
839 SDL_AtomicFetchThenIncrement64(Uint64 * ptr) | 839 SDL_AtomicFetchThenIncrement64(volatile Uint64 * ptr) |
840 { | 840 { |
841 #ifdef nativeFetchThenIncrement64 | 841 #ifdef nativeFetchThenIncrement64 |
842 return nativeFetchThenIncrement64(ptr); | 842 return nativeFetchThenIncrement64(ptr); |
843 #else | 843 #else |
844 Uint64 tmp = 0; | 844 Uint64 tmp = 0; |
851 return tmp; | 851 return tmp; |
852 #endif | 852 #endif |
853 } | 853 } |
854 | 854 |
855 Uint64 | 855 Uint64 |
856 SDL_AtomicFetchThenDecrement64(Uint64 * ptr) | 856 SDL_AtomicFetchThenDecrement64(volatile Uint64 * ptr) |
857 { | 857 { |
858 #ifdef nativeFetchThenDecrement64 | 858 #ifdef nativeFetchThenDecrement64 |
859 return nativeFetchThenDecrement64(ptr); | 859 return nativeFetchThenDecrement64(ptr); |
860 #else | 860 #else |
861 Uint64 tmp = 0; | 861 Uint64 tmp = 0; |
868 return tmp; | 868 return tmp; |
869 #endif | 869 #endif |
870 } | 870 } |
871 | 871 |
872 Uint64 | 872 Uint64 |
873 SDL_AtomicFetchThenAdd64(Uint64 * ptr, Uint64 value) | 873 SDL_AtomicFetchThenAdd64(volatile Uint64 * ptr, Uint64 value) |
874 { | 874 { |
875 #ifdef nativeFetchThenAdd64 | 875 #ifdef nativeFetchThenAdd64 |
876 return nativeFetchThenAdd64(ptr, value); | 876 return nativeFetchThenAdd64(ptr, value); |
877 #else | 877 #else |
878 Uint64 tmp = 0; | 878 Uint64 tmp = 0; |
885 return tmp; | 885 return tmp; |
886 #endif | 886 #endif |
887 } | 887 } |
888 | 888 |
889 Uint64 | 889 Uint64 |
890 SDL_AtomicFetchThenSubtract64(Uint64 * ptr, Uint64 value) | 890 SDL_AtomicFetchThenSubtract64(volatile Uint64 * ptr, Uint64 value) |
891 { | 891 { |
892 #ifdef nativeFetchThenSubtract64 | 892 #ifdef nativeFetchThenSubtract64 |
893 return nativeFetchThenSubtract64(ptr, value); | 893 return nativeFetchThenSubtract64(ptr, value); |
894 #else | 894 #else |
895 Uint64 tmp = 0; | 895 Uint64 tmp = 0; |
902 return tmp; | 902 return tmp; |
903 #endif | 903 #endif |
904 } | 904 } |
905 | 905 |
906 Uint64 | 906 Uint64 |
907 SDL_AtomicIncrementThenFetch64(Uint64 * ptr) | 907 SDL_AtomicIncrementThenFetch64(volatile Uint64 * ptr) |
908 { | 908 { |
909 #ifdef nativeIncrementThenFetch64 | 909 #ifdef nativeIncrementThenFetch64 |
910 return nativeIncrementThenFetch64(ptr); | 910 return nativeIncrementThenFetch64(ptr); |
911 #else | 911 #else |
912 Uint64 tmp = 0; | 912 Uint64 tmp = 0; |
919 return tmp; | 919 return tmp; |
920 #endif | 920 #endif |
921 } | 921 } |
922 | 922 |
923 Uint64 | 923 Uint64 |
924 SDL_AtomicDecrementThenFetch64(Uint64 * ptr) | 924 SDL_AtomicDecrementThenFetch64(volatile Uint64 * ptr) |
925 { | 925 { |
926 #ifdef nativeDecrementThenFetch64 | 926 #ifdef nativeDecrementThenFetch64 |
927 return nativeDecrementThenFetch64(ptr); | 927 return nativeDecrementThenFetch64(ptr); |
928 #else | 928 #else |
929 Uint64 tmp = 0; | 929 Uint64 tmp = 0; |
936 return tmp; | 936 return tmp; |
937 #endif | 937 #endif |
938 } | 938 } |
939 | 939 |
940 Uint64 | 940 Uint64 |
941 SDL_AtomicAddThenFetch64(Uint64 * ptr, Uint64 value) | 941 SDL_AtomicAddThenFetch64(volatile Uint64 * ptr, Uint64 value) |
942 { | 942 { |
943 #ifdef nativeAddThenFetch64 | 943 #ifdef nativeAddThenFetch64 |
944 return nativeAddThenFetch64(ptr, value); | 944 return nativeAddThenFetch64(ptr, value); |
945 #else | 945 #else |
946 Uint64 tmp = 0; | 946 Uint64 tmp = 0; |
953 return tmp; | 953 return tmp; |
954 #endif | 954 #endif |
955 } | 955 } |
956 | 956 |
957 Uint64 | 957 Uint64 |
958 SDL_AtomicSubtractThenFetch64(Uint64 * ptr, Uint64 value) | 958 SDL_AtomicSubtractThenFetch64(volatile Uint64 * ptr, Uint64 value) |
959 { | 959 { |
960 #ifdef nativeSubtractThenFetch64 | 960 #ifdef nativeSubtractThenFetch64 |
961 return nativeSubtractThenFetch64(ptr, value); | 961 return nativeSubtractThenFetch64(ptr, value); |
962 #else | 962 #else |
963 Uint64 tmp = 0; | 963 Uint64 tmp = 0; |