summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2020-04-30 23:30:22 -0700
committerMichael Pavone <pavone@retrodev.com>2020-04-30 23:30:22 -0700
commite872964e6a147ef0e1f5a14913127660b6627a5e (patch)
tree2981c8c8a7a233bfd0d6836a661a7011cffcc582
parentf6cf347dc78e3d7032dbd0b4aa9411bcccf34ac3 (diff)
Remove usage of GCC pointer arithmetic on void * extension
-rw-r--r--Makefile4
-rw-r--r--backend.c4
-rw-r--r--blastem.c5
-rwxr-xr-xrender_sdl.c8
-rw-r--r--romdb.c4
5 files changed, 14 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 1fcc94e..82e9e21 100644
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,7 @@ SDL2_PREFIX:="sdl/x86_64-w64-mingw32"
GLUDIR:=x64
endif
GLEW32S_LIB:=$(GLEW_PREFIX)/lib/Release/$(GLUDIR)/glew32s.lib
-CFLAGS:=-std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration
+CFLAGS:=-std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -Wpointer-arith -Werror=pointer-arith
LDFLAGS:=-lm -lmingw32 -lws2_32 -mwindows
ifneq ($(MAKECMDGOALS),libblastem.dll)
CFLAGS+= -I"$(SDL2_PREFIX)/include/SDL2" -I"$(GLEW_PREFIX)/include" -DGLEW_STATIC
@@ -47,7 +47,7 @@ NET:=net.o
EXE:=
HAS_PROC:=$(shell if [ -d /proc ]; then /bin/echo -e -DHAS_PROC; fi)
-CFLAGS:=-std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -Wno-unused-value $(HAS_PROC) -DHAVE_UNISTD_H
+CFLAGS:=-std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -Wno-unused-value -Wpointer-arith -Werror=pointer-arith $(HAS_PROC) -DHAVE_UNISTD_H
ifeq ($(OS),Darwin)
LIBS=sdl2 glew
diff --git a/backend.c b/backend.c
index 4629c16..595e9da 100644
--- a/backend.c
+++ b/backend.c
@@ -83,7 +83,7 @@ void * get_native_pointer(uint32_t address, void ** mem_pointers, cpu_options *
: memmap[chunk].buffer;
if (!base) {
if (memmap[chunk].flags & MMAP_AUX_BUFF) {
- return memmap[chunk].buffer + (address & memmap[chunk].aux_mask);
+ return ((uint8_t *)memmap[chunk].buffer) + (address & memmap[chunk].aux_mask);
}
return NULL;
}
@@ -108,7 +108,7 @@ void * get_native_write_pointer(uint32_t address, void ** mem_pointers, cpu_opti
: memmap[chunk].buffer;
if (!base) {
if (memmap[chunk].flags & MMAP_AUX_BUFF) {
- return memmap[chunk].buffer + (address & memmap[chunk].aux_mask);
+ return ((uint8_t *)memmap[chunk].buffer) + (address & memmap[chunk].aux_mask);
}
return NULL;
}
diff --git a/blastem.c b/blastem.c
index 8939f94..4889522 100644
--- a/blastem.c
+++ b/blastem.c
@@ -158,8 +158,9 @@ uint32_t load_rom_zip(const char *filename, void **dst)
for (offset = 0; offset + SMD_BLOCK_SIZE + SMD_HEADER_SIZE <= out_size; offset += SMD_BLOCK_SIZE)
{
uint8_t tmp[SMD_BLOCK_SIZE];
- memcpy(tmp, *dst + offset + SMD_HEADER_SIZE, SMD_BLOCK_SIZE);
- process_smd_block(*dst + offset, tmp, SMD_BLOCK_SIZE);
+ uint8_t *u8dst = *dst;
+ memcpy(tmp, u8dst + offset + SMD_HEADER_SIZE, SMD_BLOCK_SIZE);
+ process_smd_block((void *)(u8dst + offset), tmp, SMD_BLOCK_SIZE);
}
out_size = offset;
}
diff --git a/render_sdl.c b/render_sdl.c
index 5526dd7..1077109 100755
--- a/render_sdl.c
+++ b/render_sdl.c
@@ -1361,14 +1361,14 @@ uint32_t *render_get_framebuffer(uint8_t which, int *pitch)
warning("Request for invalid framebuffer number %d\n", which);
return NULL;
}
- void *pixels;
- if (SDL_LockTexture(sdl_textures[which], NULL, &pixels, pitch) < 0) {
+ uint8_t *pixels;
+ if (SDL_LockTexture(sdl_textures[which], NULL, (void **)&pixels, pitch) < 0) {
warning("Failed to lock texture: %s\n", SDL_GetError());
return NULL;
}
static uint8_t last;
if (which <= FRAMEBUFFER_EVEN) {
- locked_pixels = pixels;
+ locked_pixels = (uint32_t *)pixels;
if (which == FRAMEBUFFER_EVEN) {
pixels += *pitch;
}
@@ -1378,7 +1378,7 @@ uint32_t *render_get_framebuffer(uint8_t which, int *pitch)
}
last = which;
}
- return pixels;
+ return (uint32_t *)pixels;
#ifndef DISABLE_OPENGL
}
#endif
diff --git a/romdb.c b/romdb.c
index 210c4fd..473707b 100644
--- a/romdb.c
+++ b/romdb.c
@@ -675,7 +675,9 @@ void map_iter_fun(char *key, tern_val val, uint8_t valtype, void *data)
*map = lock_info.map[i];
if (map->start < 0x200000) {
if (map->buffer) {
- map->buffer += (0x200000 - map->start) & ((map->flags & MMAP_AUX_BUFF) ? map->aux_mask : map->mask);
+ uint8_t *buf = map->buffer;
+ buf += (0x200000 - map->start) & ((map->flags & MMAP_AUX_BUFF) ? map->aux_mask : map->mask);
+ map->buffer = buf;
}
map->start = 0x200000;
}