Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Checks: >
-bugprone-suspicious-include,
-bugprone-switch-missing-default-case,
-bugprone-branch-clone,
-bugprone-incorrect-roundings,
-bugprone-multi-level-implicit-pointer-conversion,
-clang-analyzer-deadcode.DeadStores,
-clang-analyzer-optin.portability.UnixAPI,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
Expand All @@ -49,6 +51,13 @@ FormatStyle: none
# - suspicious-include: project includes .c files in a couple of dispatch headers.
# - switch-missing-default-case: cosmetic; switches on bit-field decode patterns
# commonly omit default because all valid bit values are handled.
# - incorrect-roundings: src/core/event.h's USEC_TO_RISC_CYCLES /
# USEC_TO_M68K_CYCLES use the (double + 0.5) integer-cast idiom for
# cycle conversion. lround() is C99 (we're C89/GNU89), and the
# inputs are non-negative so the idiom is correct here.
# - multi-level-implicit-pointer-conversion: dlsym() returns void*
# that test harnesses cast directly to function pointers / data
# pointer-to-pointer; canonical idiom in the libretro dlsym pattern.
# - branch-clone: register-decode if-chains in src/cd/cdrom.c and src/tom/tom.c
# intentionally write the same value for several adjacent register addresses
# to make the address->effect mapping legible. Real bug clones are caught
Expand Down
1 change: 1 addition & 0 deletions src/core/jaguar.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,7 @@ void JaguarDone(void)
DSPDone();
TOMDone();
JERRYDone();
m68k_done();
}

uint8_t * GetRamPtr(void)
Expand Down
18 changes: 16 additions & 2 deletions src/m68000/m68kinterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,25 @@ void M68KDebugResume(void)
}


// File-scope so m68k_done() below can reset it after freeing table68k.
static uint32_t emulation_initialized = 0;

// Free process-lifetime allocations made by read_table68k(). Called
// from JaguarDone() so ASAN runs see a clean shutdown.
extern struct instr * table68k;
Comment thread
JoeMatt marked this conversation as resolved.
Outdated
void m68k_done(void)
{
if (table68k)
{
free(table68k);
table68k = NULL;
}
Comment thread
JoeMatt marked this conversation as resolved.
Outdated
emulation_initialized = 0;
}

// Pulse the RESET line on the CPU
void m68k_pulse_reset(void)
{
static uint32_t emulation_initialized = 0;

// The first call to this function initializes the opcode handler jump table
if (!emulation_initialized)
{
Expand Down
1 change: 1 addition & 0 deletions src/m68000/m68kinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ typedef enum
#define M68K_INT_ACK_SPURIOUS 0xFFFFFFFE

void m68k_pulse_reset(void);
void m68k_done(void);
int m68k_execute(int num_cycles);
void m68k_set_irq(unsigned int int_level);

Expand Down
14 changes: 14 additions & 0 deletions src/tom/gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,20 @@ void GPUInit(void)
GPUReset();
}

void GPUDone(void)
{
/* Release the branch-condition LUT so process-lifetime ASAN runs
* don't report it as a leak. Safe to call without a matching
* GPUInit (free(NULL) is a no-op) and safe to re-call after a
* subsequent GPUInit (build_branch_condition_table early-outs on
* non-NULL pointer). */
if (branch_condition_table)
{
free(branch_condition_table);
branch_condition_table = NULL;
}
Comment thread
JoeMatt marked this conversation as resolved.
Outdated
}

void GPUReset(void)
{
unsigned i;
Expand Down
1 change: 1 addition & 0 deletions src/tom/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extern "C" {
#define GPU_WORK_RAM_BASE 0x00F03000

void GPUInit(void);
void GPUDone(void);
void GPUReset(void);
void GPUExec(int32_t);
void GPUUpdateRegisterBanks(void);
Expand Down
1 change: 1 addition & 0 deletions src/tom/tom.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,7 @@ void TOMDone(void)
{
OPDone();
BlitterDone();
GPUDone();
}


Expand Down
1 change: 1 addition & 0 deletions test/test_hle_bios.c
Original file line number Diff line number Diff line change
Expand Up @@ -3172,6 +3172,7 @@ int main(int argc, char *argv[])

printf("\n=== Results: %d passed, %d failed ===\n", passes, fails);

p_retro_unload_game(); /* matches the second p_retro_load_game above; without this, JaguarDone() never runs and ASAN reports table68k + branch_condition_table as leaks */
Comment thread
JoeMatt marked this conversation as resolved.
Outdated
p_retro_deinit();
dlclose(handle);
free(dummy_rom);
Expand Down
Loading