mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-09-03 14:23:18 +02:00
Avoid strict aliasing violations. Closes #593
This commit is contained in:
@@ -100,7 +100,7 @@ static void update_sample(GB_gameboy_t *gb, GB_channel_t index, int8_t value, un
|
|||||||
output.left = output.right = 0;
|
output.left = output.right = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*(uint32_t *)&(gb->apu_output.current_sample[index]) != *(uint32_t *)&output) {
|
if (gb->apu_output.current_sample[index].packed != output.packed) {
|
||||||
refresh_channel(gb, index, cycles_offset);
|
refresh_channel(gb, index, cycles_offset);
|
||||||
gb->apu_output.current_sample[index] = output;
|
gb->apu_output.current_sample[index] = output;
|
||||||
}
|
}
|
||||||
@@ -131,7 +131,7 @@ static void update_sample(GB_gameboy_t *gb, GB_channel_t index, int8_t value, un
|
|||||||
if (likely(!gb->apu_output.channel_muted[index])) {
|
if (likely(!gb->apu_output.channel_muted[index])) {
|
||||||
output = (GB_sample_t){(0xF - value * 2) * left_volume, (0xF - value * 2) * right_volume};
|
output = (GB_sample_t){(0xF - value * 2) * left_volume, (0xF - value * 2) * right_volume};
|
||||||
}
|
}
|
||||||
if (*(uint32_t *)&(gb->apu_output.current_sample[index]) != *(uint32_t *)&output) {
|
if (gb->apu_output.current_sample[index].packed != output.packed) {
|
||||||
refresh_channel(gb, index, cycles_offset);
|
refresh_channel(gb, index, cycles_offset);
|
||||||
gb->apu_output.current_sample[index] = output;
|
gb->apu_output.current_sample[index] = output;
|
||||||
}
|
}
|
||||||
|
11
Core/apu.h
11
Core/apu.h
@@ -25,11 +25,22 @@
|
|||||||
|
|
||||||
/* APU ticks are 2MHz, triggered by an internal APU clock. */
|
/* APU ticks are 2MHz, triggered by an internal APU clock. */
|
||||||
|
|
||||||
|
#ifdef GB_INTERNAL
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
int16_t left;
|
||||||
|
int16_t right;
|
||||||
|
};
|
||||||
|
uint32_t packed;
|
||||||
|
} GB_sample_t;
|
||||||
|
#else
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int16_t left;
|
int16_t left;
|
||||||
int16_t right;
|
int16_t right;
|
||||||
} GB_sample_t;
|
} GB_sample_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
2
Makefile
2
Makefile
@@ -164,7 +164,7 @@ endif
|
|||||||
|
|
||||||
# These must come before the -Wno- flags
|
# These must come before the -Wno- flags
|
||||||
WARNINGS += -Werror -Wall -Wno-unknown-warning -Wno-unknown-warning-option -Wno-missing-braces
|
WARNINGS += -Werror -Wall -Wno-unknown-warning -Wno-unknown-warning-option -Wno-missing-braces
|
||||||
WARNINGS += -Wno-nonnull -Wno-unused-result -Wno-strict-aliasing -Wno-multichar -Wno-int-in-bool-context -Wno-format-truncation
|
WARNINGS += -Wno-nonnull -Wno-unused-result -Wno-multichar -Wno-int-in-bool-context -Wno-format-truncation
|
||||||
|
|
||||||
# Only add this flag if the compiler supports it
|
# Only add this flag if the compiler supports it
|
||||||
ifeq ($(shell $(CC) -x c -c $(NULL) -o $(NULL) -Werror -Wpartial-availability 2> $(NULL); echo $$?),0)
|
ifeq ($(shell $(CC) -x c -c $(NULL) -o $(NULL) -Werror -Wpartial-availability 2> $(NULL); echo $$?),0)
|
||||||
|
Reference in New Issue
Block a user