mirror of https://github.com/inolen/redream.git
windows build fixes
This commit is contained in:
parent
acd9e6c4a9
commit
55da995676
|
@ -303,6 +303,15 @@ gdb_server_t *gdb_server_create(gdb_target_t *target, int port) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
WSADATA wsadata;
|
||||
int r = WSAStartup(MAKEWORD(2, 2), &wsadata);
|
||||
if (r) {
|
||||
GDB_SERVER_LOG("Failed to initialize WinSock");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
gdb_server_t *sv = (gdb_server_t *)GDB_SERVER_MALLOC(sizeof(gdb_server_t));
|
||||
memset(sv, 0, sizeof(*sv));
|
||||
sv->target = *target;
|
||||
|
@ -310,8 +319,8 @@ gdb_server_t *gdb_server_create(gdb_target_t *target, int port) {
|
|||
sv->client = INVALID_SOCKET;
|
||||
|
||||
if (gdb_server_create_listen(sv, port) == -1) {
|
||||
GDB_SERVER_FREE(sv);
|
||||
sv = NULL;
|
||||
gdb_server_destroy(sv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return sv;
|
||||
|
@ -346,6 +355,11 @@ void gdb_server_destroy(gdb_server_t *sv) {
|
|||
gdb_server_destroy_listen(sv);
|
||||
|
||||
GDB_SERVER_FREE(sv);
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
int r = WSACleanup();
|
||||
GDB_SERVER_ASSERT(r == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -414,6 +428,10 @@ static int gdb_server_create_listen(gdb_server_t *sv, int port) {
|
|||
// destroy the listen server
|
||||
//
|
||||
static void gdb_server_destroy_listen(gdb_server_t *sv) {
|
||||
if (sv->listen == INVALID_SOCKET) {
|
||||
return;
|
||||
}
|
||||
|
||||
gdb_server_destroy_client(sv);
|
||||
|
||||
shutdown(sv->listen, SHUT_RDWR);
|
||||
|
|
|
@ -54,7 +54,7 @@ const char *format_check_error(const char *filename, int linenum,
|
|||
do { \
|
||||
if (!CHECK_EXPECT_TRUE(!strcmp(v1, v2))) { \
|
||||
const char *msg = FORMAT_CHECK_ERROR( \
|
||||
__FILE__, __LINE__, "Expected '" #v1 "' to eq '" #v2 "'", 0, \
|
||||
__FILE__, __LINE__, "expected '" #v1 "' to eq '" #v2 "'", 0, \
|
||||
##__VA_ARGS__); \
|
||||
LOG_FATAL(msg); \
|
||||
} \
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "core/sort.h"
|
||||
|
||||
static void merge(void *in, void *out, size_t size, int l, int m, int r,
|
||||
static void merge(uint8_t *in, uint8_t *out, size_t size, int l, int m, int r,
|
||||
sort_cmp cmp) {
|
||||
int i = l;
|
||||
int j = m;
|
||||
|
@ -21,7 +22,7 @@ static void merge(void *in, void *out, size_t size, int l, int m, int r,
|
|||
}
|
||||
}
|
||||
|
||||
static void msort_r(void *in, void *out, size_t size, int l, int r,
|
||||
static void msort_r(uint8_t *in, uint8_t *out, size_t size, int l, int r,
|
||||
sort_cmp cmp) {
|
||||
if ((r - l) < 2) {
|
||||
return;
|
||||
|
|
|
@ -42,7 +42,7 @@ void cond_destroy(cond_t cond);
|
|||
* sleeping
|
||||
*/
|
||||
#if PLATFORM_WINDOWS
|
||||
#include <Synchapi.h>
|
||||
#include <windows.h>
|
||||
#define sleep Sleep
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
|
|
@ -131,10 +131,12 @@ int dc_load(struct dreamcast *dc, const char *path) {
|
|||
|
||||
int dc_init(struct dreamcast *dc) {
|
||||
if (dc->debugger && !debugger_init(dc->debugger)) {
|
||||
LOG_WARNING("failed to initialize debugger");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!memory_init(dc->memory)) {
|
||||
LOG_WARNING("failed to initialize shared memory");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -159,11 +161,13 @@ int dc_init(struct dreamcast *dc) {
|
|||
/* initialize each device */
|
||||
list_for_each_entry(dev, &dc->devices, struct device, it) {
|
||||
if (!dev->init(dev)) {
|
||||
LOG_WARNING("failed to initialize device '%s'", dev->name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bios_init(dc->bios)) {
|
||||
LOG_WARNING("failed to initialize bios");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -362,7 +362,7 @@ static void *emu_video_thread(void *data) {
|
|||
struct emu *emu = data;
|
||||
|
||||
/* make secondary context active for this thread */
|
||||
r_make_current(emu->r2);
|
||||
r_bind_context(emu->r2);
|
||||
|
||||
while (1) {
|
||||
mutex_lock(emu->pending_mutex);
|
||||
|
@ -399,6 +399,10 @@ static void *emu_video_thread(void *data) {
|
|||
mutex_unlock(emu->pending_mutex);
|
||||
}
|
||||
|
||||
/* unbind context from this thread before it dies, otherwise the main thread
|
||||
may not be able to bind it in order to clean it up */
|
||||
r_unbind_context(emu->r2);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -619,7 +623,7 @@ static void emu_host_context_destroyed(void *userdata) {
|
|||
/* destroy the video thread */
|
||||
if (emu->multi_threaded) {
|
||||
mutex_lock(emu->pending_mutex);
|
||||
emu->pending_ctx = (struct tile_context *)0xdeadbeef;
|
||||
emu->pending_ctx = (struct tile_context *)(intptr_t)0xdeadbeef;
|
||||
cond_signal(emu->pending_cond);
|
||||
mutex_unlock(emu->pending_mutex);
|
||||
|
||||
|
@ -632,8 +636,7 @@ static void emu_host_context_destroyed(void *userdata) {
|
|||
|
||||
/* destroy video renderer */
|
||||
struct render_backend *r2 = emu_video_renderer(emu);
|
||||
|
||||
r_make_current(r2);
|
||||
r_bind_context(r2);
|
||||
|
||||
r_destroy_framebuffer(r2, emu->video_fb);
|
||||
if (emu->video_sync) {
|
||||
|
@ -647,7 +650,7 @@ static void emu_host_context_destroyed(void *userdata) {
|
|||
}
|
||||
|
||||
/* destroy primary renderer */
|
||||
r_make_current(emu->r);
|
||||
r_bind_context(emu->r);
|
||||
|
||||
mp_destroy(emu->mp);
|
||||
imgui_destroy(emu->imgui);
|
||||
|
@ -674,20 +677,19 @@ static void emu_host_context_reset(void *userdata) {
|
|||
}
|
||||
|
||||
struct render_backend *r2 = emu_video_renderer(emu);
|
||||
|
||||
r_make_current(r2);
|
||||
r_bind_context(r2);
|
||||
|
||||
emu->video_fb = r_create_framebuffer(r2, emu->video_width, emu->video_height,
|
||||
&emu->video_tex);
|
||||
|
||||
/* make primary renderer active for the current thread */
|
||||
r_bind_context(emu->r);
|
||||
|
||||
/* startup video thread */
|
||||
if (emu->multi_threaded) {
|
||||
emu->video_thread = thread_create(&emu_video_thread, NULL, emu);
|
||||
CHECK_NOTNULL(emu->video_thread);
|
||||
}
|
||||
|
||||
/* make primary renderer active for the current thread */
|
||||
r_make_current(emu->r);
|
||||
}
|
||||
|
||||
static void emu_host_resized(void *userdata) {
|
||||
|
|
|
@ -21,7 +21,7 @@ static int gdi_read_sector(struct disc *disc, int fad, enum gd_secfmt fmt,
|
|||
CHECK(mask == MASK_DATA);
|
||||
|
||||
/* open the file backing the track */
|
||||
int n = track - gdi->tracks;
|
||||
int n = (int)(track - gdi->tracks);
|
||||
FILE *fp = gdi->files[n];
|
||||
|
||||
if (!fp) {
|
||||
|
|
|
@ -207,7 +207,7 @@ static void gdrom_spi_data(struct gdrom *gd, int arg) {
|
|||
int offset = gd->pio_offset;
|
||||
uint8_t *data = gd->pio_buffer;
|
||||
int size = gd->pio_size;
|
||||
memcpy((void *)&gd->hw_info + offset, data, size);
|
||||
memcpy((uint8_t *)&gd->hw_info + offset, data, size);
|
||||
|
||||
gdrom_spi_end(gd);
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ static void gdrom_spi_cmd(struct gdrom *gd, int arg) {
|
|||
int offset = data[2];
|
||||
int size = data[4];
|
||||
|
||||
gdrom_spi_write(gd, (void *)&gd->hw_info + offset, size);
|
||||
gdrom_spi_write(gd, (uint8_t *)&gd->hw_info + offset, size);
|
||||
} break;
|
||||
|
||||
case SPI_REQ_ERROR: {
|
||||
|
|
|
@ -64,7 +64,7 @@ static int boot_load_rom(struct boot *boot) {
|
|||
fclose(fp);
|
||||
|
||||
if (!boot_validate(boot)) {
|
||||
LOG_WARNING("invalid BIOS file");
|
||||
LOG_WARNING("failed to validate boot rom");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ static void interp_backend_run_code(struct jit_backend *base, int cycles) {
|
|||
struct interp_backend *backend = (struct interp_backend *)base;
|
||||
struct jit *jit = backend->jit;
|
||||
struct jit_guest *guest = jit->guest;
|
||||
void *ctx = guest->ctx;
|
||||
uint32_t *pc = ctx + guest->offset_pc;
|
||||
int32_t *run_cycles = ctx + guest->offset_cycles;
|
||||
int32_t *ran_instrs = ctx + guest->offset_instrs;
|
||||
uint8_t *ctx = guest->ctx;
|
||||
uint32_t *pc = (uint32_t *)(ctx + guest->offset_pc);
|
||||
int32_t *run_cycles = (int32_t *)(ctx + guest->offset_cycles);
|
||||
int32_t *ran_instrs = (int32_t *)(ctx + guest->offset_instrs);
|
||||
|
||||
*run_cycles = cycles;
|
||||
*ran_instrs = 0;
|
||||
|
|
|
@ -829,7 +829,11 @@ void r_set_debug_flag(struct render_backend *r, int flag) {
|
|||
r->debug_flags |= flag;
|
||||
}
|
||||
|
||||
void r_make_current(struct render_backend *r) {
|
||||
void r_unbind_context(struct render_backend *r) {
|
||||
video_gl_make_current(r->host, NULL);
|
||||
}
|
||||
|
||||
void r_bind_context(struct render_backend *r) {
|
||||
video_gl_make_current(r->host, r->ctx);
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,8 @@ struct render_backend *r_create(struct host *host);
|
|||
struct render_backend *r_create_from(struct render_backend *other);
|
||||
void r_destroy(struct render_backend *rc);
|
||||
|
||||
void r_make_current(struct render_backend *r);
|
||||
void r_bind_context(struct render_backend *r);
|
||||
void r_unbind_context(struct render_backend *r);
|
||||
|
||||
void r_set_debug_flag(struct render_backend *r, int flag);
|
||||
int r_get_debug_flag(struct render_backend *r, int flag);
|
||||
|
|
|
@ -559,7 +559,7 @@ static void tracer_render_side_menu(struct tracer *tracer) {
|
|||
igSetWindowPos(pos, ImGuiSetCond_Once);
|
||||
|
||||
int i = 0;
|
||||
int tex_per_row = MAX(igGetContentRegionAvailWidth() / 44, 1);
|
||||
int tex_per_row = MAX((int)(igGetContentRegionAvailWidth() / 44.0f), 1);
|
||||
|
||||
rb_for_each_entry(tex, &tracer->live_textures, struct tracer_texture,
|
||||
live_it) {
|
||||
|
|
Loading…
Reference in New Issue