@@ -342,11 +342,10 @@ static void clear_local_cache(void)
342
342
static noinline void ari64_execute_threaded_slow (struct psxRegisters * regs ,
343
343
enum blockExecCaller block_caller )
344
344
{
345
- if (! ndrc_g .thread .busy ) {
345
+ if (ndrc_g .thread .busy_addr == ~ 0u ) {
346
346
memcpy (ndrc_smrv_regs , regs -> GPR .r , sizeof (ndrc_smrv_regs ));
347
347
slock_lock (ndrc_g .thread .lock );
348
- ndrc_g .thread .addr = regs -> pc ;
349
- ndrc_g .thread .busy = 1 ;
348
+ ndrc_g .thread .busy_addr = regs -> pc ;
350
349
slock_unlock (ndrc_g .thread .lock );
351
350
scond_signal (ndrc_g .thread .cond );
352
351
}
@@ -357,7 +356,7 @@ static noinline void ari64_execute_threaded_slow(struct psxRegisters *regs,
357
356
{
358
357
psxInt .ExecuteBlock (regs , block_caller );
359
358
}
360
- while (!regs -> stop && ndrc_g .thread .busy && block_caller == EXEC_CALLER_OTHER );
359
+ while (!regs -> stop && ndrc_g .thread .busy_addr != ~ 0u && block_caller == EXEC_CALLER_OTHER );
361
360
362
361
psxInt .Notify (R3000ACPU_NOTIFY_BEFORE_SAVE , NULL );
363
362
//ari64_notify(R3000ACPU_NOTIFY_AFTER_LOAD, NULL);
@@ -372,8 +371,7 @@ static void ari64_execute_threaded_once(struct psxRegisters *regs,
372
371
* (void * * )((char * )drc_local + LO_hash_table_ptr );
373
372
void * target ;
374
373
375
- if (likely (!ndrc_g .thread .busy )) {
376
- ndrc_g .thread .addr = 0 ;
374
+ if (likely (ndrc_g .thread .busy_addr == ~0u )) {
377
375
target = ndrc_get_addr_ht_param (hash_table , regs -> pc ,
378
376
ndrc_cm_no_compile );
379
377
if (target ) {
@@ -412,21 +410,21 @@ static void ari64_execute_threaded_block(struct psxRegisters *regs,
412
410
413
411
static void ari64_thread_sync (void )
414
412
{
415
- if (!ndrc_g .thread .lock || ! ndrc_g .thread .busy )
413
+ if (!ndrc_g .thread .lock || ndrc_g .thread .busy_addr == ~ 0u )
416
414
return ;
417
415
for (;;) {
418
416
slock_lock (ndrc_g .thread .lock );
419
417
slock_unlock (ndrc_g .thread .lock );
420
- if (! ndrc_g .thread .busy )
418
+ if (ndrc_g .thread .busy_addr == ~ 0 )
421
419
break ;
422
420
retro_sleep (0 );
423
421
}
424
422
}
425
423
426
424
static int ari64_thread_check_range (unsigned int start , unsigned int end )
427
425
{
428
- u32 addr = ndrc_g .thread .addr ;
429
- if (! addr )
426
+ u32 addr = ndrc_g .thread .busy_addr ;
427
+ if (addr == ~ 0u )
430
428
return 0 ;
431
429
432
430
addr &= 0x1fffffff ;
@@ -451,16 +449,17 @@ static void ari64_compile_thread(void *unused)
451
449
slock_lock (ndrc_g .thread .lock );
452
450
while (!ndrc_g .thread .exit )
453
451
{
454
- if (!ndrc_g .thread .busy )
452
+ addr = * (volatile unsigned int * )& ndrc_g .thread .busy_addr ;
453
+ if (addr == ~0u )
455
454
scond_wait (ndrc_g .thread .cond , ndrc_g .thread .lock );
456
- addr = ndrc_g .thread .addr ;
457
- if (! ndrc_g . thread . busy || ! addr || ndrc_g .thread .exit )
455
+ addr = * ( volatile unsigned int * ) & ndrc_g .thread .busy_addr ;
456
+ if (addr == ~ 0u || ndrc_g .thread .exit )
458
457
continue ;
459
458
460
459
target = ndrc_get_addr_ht_param (hash_table , addr ,
461
460
ndrc_cm_compile_in_thread );
462
461
//printf("c %08x -> %p\n", addr, target);
463
- ndrc_g .thread .busy = 0 ;
462
+ ndrc_g .thread .busy_addr = ~ 0u ;
464
463
}
465
464
slock_unlock (ndrc_g .thread .lock );
466
465
(void )target ;
@@ -490,7 +489,7 @@ static void ari64_thread_shutdown(void)
490
489
slock_free (ndrc_g .thread .lock );
491
490
ndrc_g .thread .lock = NULL ;
492
491
}
493
- ndrc_g .thread .busy = ndrc_g . thread . addr = 0 ;
492
+ ndrc_g .thread .busy_addr = ~ 0u ;
494
493
}
495
494
496
495
static void ari64_thread_init (void )
@@ -514,7 +513,8 @@ static void ari64_thread_init(void)
514
513
return ;
515
514
516
515
ari64_thread_shutdown ();
517
- ndrc_g .thread .busy = ndrc_g .thread .addr = ndrc_g .thread .exit = 0 ;
516
+ ndrc_g .thread .exit = 0 ;
517
+ ndrc_g .thread .busy_addr = ~0u ;
518
518
519
519
if (enable ) {
520
520
ndrc_g .thread .lock = slock_new ();
0 commit comments