| 320 | } |
| 321 | |
| 322 | static int popInterrupt(void) |
| 323 | { |
| 324 | int curEvt; |
| 325 | bool strexFailed; |
| 326 | u8* gspEventData = (u8*)gspSharedMem + gspThreadId*0x40; |
| 327 | do { |
| 328 | union { |
| 329 | struct { |
| 330 | u8 cur; |
| 331 | u8 count; |
| 332 | u8 err; |
| 333 | u8 unused; |
| 334 | }; |
| 335 | u32 as_u32; |
| 336 | } header; |
| 337 | |
| 338 | // Do a load on all header fields as an atomic unit |
| 339 | header.as_u32 = __ldrex((s32*)gspEventData); |
| 340 | |
| 341 | if (__builtin_expect(header.count == 0, 0)) { |
| 342 | __clrex(); |
| 343 | return -1; |
| 344 | } |
| 345 | |
| 346 | curEvt = gspEventData[0xC + header.cur]; |
| 347 | |
| 348 | header.cur += 1; |
| 349 | if (header.cur >= 0x34) header.cur -= 0x34; |
| 350 | header.count -= 1; |
| 351 | header.err = 0; // Should this really be set? |
| 352 | |
| 353 | strexFailed = __strex((s32*)gspEventData, header.as_u32); |
| 354 | } while (__builtin_expect(strexFailed, 0)); |
| 355 | |
| 356 | return curEvt; |
| 357 | } |
| 358 | |
| 359 | // Dummy version to avoid linking in gxqueue.c if not actually used |
| 360 | __attribute__((weak)) void gxCmdQueueInterrupt(GSPGPU_Event irq) |
no test coverage detected