clang-format in src/unix/

This commit is contained in:
Jasmine Iwanek
2022-09-18 17:17:34 -04:00
parent d4c4ef6a5d
commit acbe718f1e
5 changed files with 744 additions and 848 deletions

View File

@@ -13,11 +13,10 @@
CF_IMPLICIT_BRIDGING_ENABLED
CF_EXTERN_C_BEGIN
void getDefaultROMPath(char*);
void getDefaultROMPath(char *);
int toto();
CF_EXTERN_C_END
CF_IMPLICIT_BRIDGING_DISABLED
#endif /* macOSXGlue_h */

File diff suppressed because it is too large Load Diff

View File

@@ -39,8 +39,6 @@
#include <86box/plat.h>
#include <86box/ui.h>
void
cassette_mount(char *fn, uint8_t wp)
{
@@ -51,47 +49,43 @@ cassette_mount(char *fn, uint8_t wp)
if (fn != NULL)
memcpy(cassette_fname, fn, MIN(511, strlen(fn)));
ui_sb_update_icon_state(SB_CASSETTE, (fn == NULL) ? 1 : 0);
//media_menu_update_cassette();
// media_menu_update_cassette();
ui_sb_update_tip(SB_CASSETTE);
config_save();
}
void
cassette_eject(void)
{
pc_cas_set_fname(cassette, NULL);
memset(cassette_fname, 0x00, sizeof(cassette_fname));
ui_sb_update_icon_state(SB_CASSETTE, 1);
//media_menu_update_cassette();
// media_menu_update_cassette();
ui_sb_update_tip(SB_CASSETTE);
config_save();
}
void
cartridge_mount(uint8_t id, char *fn, uint8_t wp)
{
cart_close(id);
cart_load(id, fn);
ui_sb_update_icon_state(SB_CARTRIDGE | id, strlen(cart_fns[id]) ? 0 : 1);
//media_menu_update_cartridge(id);
// media_menu_update_cartridge(id);
ui_sb_update_tip(SB_CARTRIDGE | id);
config_save();
}
void
cartridge_eject(uint8_t id)
{
cart_close(id);
ui_sb_update_icon_state(SB_CARTRIDGE | id, 1);
//media_menu_update_cartridge(id);
// media_menu_update_cartridge(id);
ui_sb_update_tip(SB_CARTRIDGE | id);
config_save();
}
void
floppy_mount(uint8_t id, char *fn, uint8_t wp)
{
@@ -99,36 +93,34 @@ floppy_mount(uint8_t id, char *fn, uint8_t wp)
ui_writeprot[id] = wp;
fdd_load(id, fn);
ui_sb_update_icon_state(SB_FLOPPY | id, strlen(floppyfns[id]) ? 0 : 1);
//media_menu_update_floppy(id);
// media_menu_update_floppy(id);
ui_sb_update_tip(SB_FLOPPY | id);
config_save();
}
void
floppy_eject(uint8_t id)
{
fdd_close(id);
ui_sb_update_icon_state(SB_FLOPPY | id, 1);
//media_menu_update_floppy(id);
// media_menu_update_floppy(id);
ui_sb_update_tip(SB_FLOPPY | id);
config_save();
}
void
plat_cdrom_ui_update(uint8_t id, uint8_t reload)
{
cdrom_t *drv = &cdrom[id];
if (drv->host_drive == 0) {
ui_sb_update_icon_state(SB_CDROM|id, 1);
ui_sb_update_icon_state(SB_CDROM | id, 1);
} else {
ui_sb_update_icon_state(SB_CDROM|id, 0);
ui_sb_update_icon_state(SB_CDROM | id, 0);
}
//media_menu_update_cdrom(id);
ui_sb_update_tip(SB_CDROM|id);
// media_menu_update_cdrom(id);
ui_sb_update_tip(SB_CDROM | id);
}
void
@@ -150,7 +142,7 @@ cdrom_mount(uint8_t id, char *fn)
} else {
ui_sb_update_icon_state(SB_CDROM | id, 1);
}
//media_menu_update_cdrom(id);
// media_menu_update_cdrom(id);
ui_sb_update_tip(SB_CDROM | id);
config_save();
}
@@ -167,12 +159,11 @@ mo_eject(uint8_t id)
}
ui_sb_update_icon_state(SB_MO | id, 1);
//media_menu_update_mo(id);
// media_menu_update_mo(id);
ui_sb_update_tip(SB_MO | id);
config_save();
}
void
mo_mount(uint8_t id, char *fn, uint8_t wp)
{
@@ -184,13 +175,12 @@ mo_mount(uint8_t id, char *fn, uint8_t wp)
mo_insert(dev);
ui_sb_update_icon_state(SB_MO | id, strlen(mo_drives[id].image_path) ? 0 : 1);
//media_menu_update_mo(id);
// media_menu_update_mo(id);
ui_sb_update_tip(SB_MO | id);
config_save();
}
void
mo_reload(uint8_t id)
{
@@ -198,13 +188,13 @@ mo_reload(uint8_t id)
mo_disk_reload(dev);
if (strlen(mo_drives[id].image_path) == 0) {
ui_sb_update_icon_state(SB_MO|id, 1);
ui_sb_update_icon_state(SB_MO | id, 1);
} else {
ui_sb_update_icon_state(SB_MO|id, 0);
ui_sb_update_icon_state(SB_MO | id, 0);
}
//media_menu_update_mo(id);
ui_sb_update_tip(SB_MO|id);
// media_menu_update_mo(id);
ui_sb_update_tip(SB_MO | id);
config_save();
}
@@ -221,12 +211,11 @@ zip_eject(uint8_t id)
}
ui_sb_update_icon_state(SB_ZIP | id, 1);
//media_menu_update_zip(id);
// media_menu_update_zip(id);
ui_sb_update_tip(SB_ZIP | id);
config_save();
}
void
zip_mount(uint8_t id, char *fn, uint8_t wp)
{
@@ -238,13 +227,12 @@ zip_mount(uint8_t id, char *fn, uint8_t wp)
zip_insert(dev);
ui_sb_update_icon_state(SB_ZIP | id, strlen(zip_drives[id].image_path) ? 0 : 1);
//media_menu_update_zip(id);
// media_menu_update_zip(id);
ui_sb_update_tip(SB_ZIP | id);
config_save();
}
void
zip_reload(uint8_t id)
{
@@ -252,13 +240,13 @@ zip_reload(uint8_t id)
zip_disk_reload(dev);
if (strlen(zip_drives[id].image_path) == 0) {
ui_sb_update_icon_state(SB_ZIP|id, 1);
ui_sb_update_icon_state(SB_ZIP | id, 1);
} else {
ui_sb_update_icon_state(SB_ZIP|id, 0);
ui_sb_update_icon_state(SB_ZIP | id, 0);
}
//media_menu_update_zip(id);
ui_sb_update_tip(SB_ZIP|id);
// media_menu_update_zip(id);
ui_sb_update_tip(SB_ZIP | id);
config_save();
}

View File

@@ -22,8 +22,7 @@
#define RENDERER_HARDWARE 2
#define RENDERER_OPENGL 4
typedef struct sdl_blit_params
{
typedef struct sdl_blit_params {
int x, y, w, h;
} sdl_blit_params;
extern sdl_blit_params params;
@@ -35,9 +34,9 @@ static SDL_Texture *sdl_tex = NULL;
int sdl_w = SCREEN_RES_X, sdl_h = SCREEN_RES_Y;
static int sdl_fs, sdl_flags = -1;
static int cur_w, cur_h;
static int cur_wx = 0, cur_wy = 0, cur_ww =0, cur_wh = 0;
static int cur_wx = 0, cur_wy = 0, cur_ww = 0, cur_wh = 0;
static volatile int sdl_enabled = 1;
static SDL_mutex* sdl_mutex = NULL;
static SDL_mutex *sdl_mutex = NULL;
int mouse_capture;
int title_set = 0;
int resize_pending = 0;
@@ -127,7 +126,6 @@ sdl_stretch(int *w, int *h, int *x, int *y)
}
}
void
sdl_blit_shim(int x, int y, int w, int h, int monitor_index)
{
@@ -146,7 +144,7 @@ sdl_blit_shim(int x, int y, int w, int h, int monitor_index)
void ui_window_title_real();
void
sdl_real_blit(SDL_Rect* r_src)
sdl_real_blit(SDL_Rect *r_src)
{
SDL_Rect r_dst;
int ret, winx, winy;
@@ -156,16 +154,12 @@ sdl_real_blit(SDL_Rect* r_src)
r_dst = *r_src;
r_dst.x = r_dst.y = 0;
if (sdl_fs)
{
if (sdl_fs) {
sdl_stretch(&r_dst.w, &r_dst.h, &r_dst.x, &r_dst.y);
} else {
r_dst.w *= ((float) winx / (float) r_dst.w);
r_dst.h *= ((float) winy / (float) r_dst.h);
}
else
{
r_dst.w *= ((float)winx / (float) r_dst.w);
r_dst.h *= ((float)winy / (float) r_dst.h);
}
ret = SDL_RenderCopy(sdl_render, sdl_tex, r_src, &r_dst);
if (ret)
@@ -191,9 +185,9 @@ sdl_blit(int x, int y, int w, int h)
SDL_LockMutex(sdl_mutex);
if (resize_pending)
{
if (!video_fullscreen) sdl_resize(resize_w, resize_h);
if (resize_pending) {
if (!video_fullscreen)
sdl_resize(resize_w, resize_h);
resize_pending = 0;
}
r_src.x = x;
@@ -211,11 +205,9 @@ static void
sdl_destroy_window(void)
{
if (sdl_win != NULL) {
if (window_remember)
{
if (window_remember) {
SDL_GetWindowSize(sdl_win, &window_w, &window_h);
if (strncasecmp(SDL_GetCurrentVideoDriver(), "wayland", 7) != 0)
{
if (strncasecmp(SDL_GetCurrentVideoDriver(), "wayland", 7) != 0) {
SDL_GetWindowPosition(sdl_win, &window_x, &window_y);
}
}
@@ -224,7 +216,6 @@ sdl_destroy_window(void)
}
}
static void
sdl_destroy_texture(void)
{
@@ -285,8 +276,7 @@ sdl_select_best_hw_driver(void)
int i;
SDL_RendererInfo renderInfo;
for (i = 0; i < SDL_GetNumRenderDrivers(); ++i)
{
for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
SDL_GetRenderDriverInfo(i, &renderInfo);
if (renderInfo.flags & SDL_RENDERER_ACCELERATED) {
SDL_SetHint(SDL_HINT_RENDER_DRIVER, renderInfo.name);
@@ -308,7 +298,6 @@ sdl_reinit_texture()
sdl_tex = SDL_CreateTexture(sdl_render, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING, 2048, 2048);
}
void
@@ -316,7 +305,7 @@ sdl_set_fs(int fs)
{
SDL_LockMutex(sdl_mutex);
SDL_SetWindowFullscreen(sdl_win, fs ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
SDL_SetRelativeMouseMode((SDL_bool)mouse_capture);
SDL_SetRelativeMouseMode((SDL_bool) mouse_capture);
sdl_fs = fs;
@@ -363,8 +352,7 @@ sdl_resize(int x, int y)
void
sdl_reload(void)
{
if (sdl_flags & RENDERER_HARDWARE)
{
if (sdl_flags & RENDERER_HARDWARE) {
SDL_LockMutex(sdl_mutex);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, video_filter_method ? "1" : "0");
@@ -375,7 +363,7 @@ sdl_reload(void)
}
int
plat_vidapi(char* api)
plat_vidapi(char *api)
{
return 0;
}
@@ -393,29 +381,26 @@ sdl_init_common(int flags)
/* Initialize the SDL system. */
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fprintf(stderr, "SDL: initialization failed (%s)\n", SDL_GetError());
return(0);
return (0);
}
if (flags & RENDERER_HARDWARE) {
if (flags & RENDERER_OPENGL) {
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "OpenGL");
}
else
} else
sdl_select_best_hw_driver();
}
sdl_mutex = SDL_CreateMutex();
sdl_win = SDL_CreateWindow("86Box", strncasecmp(SDL_GetCurrentVideoDriver(), "wayland", 7) != 0 && window_remember ? window_x : SDL_WINDOWPOS_CENTERED, strncasecmp(SDL_GetCurrentVideoDriver(), "wayland", 7) != 0 && window_remember ? window_y : SDL_WINDOWPOS_CENTERED, scrnsz_x, scrnsz_y, SDL_WINDOW_OPENGL | (vid_resize & 1 ? SDL_WINDOW_RESIZABLE : 0));
sdl_set_fs(video_fullscreen);
if (!(video_fullscreen & 1))
{
if (!(video_fullscreen & 1)) {
if (vid_resize & 2)
plat_resize(fixed_size_x, fixed_size_y);
else
plat_resize(scrnsz_x, scrnsz_y);
}
if ((vid_resize < 2) && window_remember)
{
if ((vid_resize < 2) && window_remember) {
SDL_SetWindowSize(sdl_win, window_w, window_h);
}
@@ -427,7 +412,7 @@ sdl_init_common(int flags)
sdl_enabled = 1;
return(1);
return (1);
}
int
@@ -436,37 +421,35 @@ sdl_inits()
return sdl_init_common(0);
}
int
sdl_inith()
{
return sdl_init_common(RENDERER_HARDWARE);
}
int
sdl_initho()
{
return sdl_init_common(RENDERER_HARDWARE | RENDERER_OPENGL);
}
int
sdl_pause(void)
{
return(0);
return (0);
}
void
plat_mouse_capture(int on)
{
SDL_LockMutex(sdl_mutex);
SDL_SetRelativeMouseMode((SDL_bool)on);
SDL_SetRelativeMouseMode((SDL_bool) on);
mouse_capture = on;
SDL_UnlockMutex(sdl_mutex);
}
void plat_resize(int w, int h)
void
plat_resize(int w, int h)
{
SDL_LockMutex(sdl_mutex);
resize_w = w;
@@ -476,21 +459,20 @@ void plat_resize(int w, int h)
}
wchar_t sdl_win_title[512] = { L'8', L'6', L'B', L'o', L'x', 0 };
SDL_mutex* titlemtx = NULL;
SDL_mutex *titlemtx = NULL;
void ui_window_title_real()
void
ui_window_title_real()
{
char* res;
if (sizeof(wchar_t) == 1)
{
SDL_SetWindowTitle(sdl_win, (char*)sdl_win_title);
char *res;
if (sizeof(wchar_t) == 1) {
SDL_SetWindowTitle(sdl_win, (char *) sdl_win_title);
return;
}
res = SDL_iconv_string("UTF-8", sizeof(wchar_t) == 2 ? "UTF-16LE" : "UTF-32LE", (char*)sdl_win_title, wcslen(sdl_win_title) * sizeof(wchar_t) + sizeof(wchar_t));
if (res)
{
res = SDL_iconv_string("UTF-8", sizeof(wchar_t) == 2 ? "UTF-16LE" : "UTF-32LE", (char *) sdl_win_title, wcslen(sdl_win_title) * sizeof(wchar_t) + sizeof(wchar_t));
if (res) {
SDL_SetWindowTitle(sdl_win, res);
SDL_free((void*)res);
SDL_free((void *) res);
}
title_set = 0;
}
@@ -498,9 +480,11 @@ extern SDL_threadID eventthread;
/* Only activate threading path on macOS, otherwise it will softlock Xorg.
Wayland doesn't seem to have this issue. */
wchar_t* ui_window_title(wchar_t* str)
wchar_t *
ui_window_title(wchar_t *str)
{
if (!str) return sdl_win_title;
if (!str)
return sdl_win_title;
#ifdef __APPLE__
if (eventthread == SDL_ThreadID())
#endif
@@ -518,10 +502,17 @@ wchar_t* ui_window_title(wchar_t* str)
return str;
}
void ui_init_monitor(int monitor_index) {}
void ui_deinit_monitor(int monitor_index) {}
void
ui_init_monitor(int monitor_index)
{
}
void
ui_deinit_monitor(int monitor_index)
{
}
void plat_resize_request(int w, int h, int monitor_index)
void
plat_resize_request(int w, int h, int monitor_index)
{
atomic_store((&doresize_monitors[monitor_index]), 1);
}

View File

@@ -7,30 +7,23 @@
#include <86box/plat.h>
#include <86box/thread.h>
typedef struct event_pthread_t
{
typedef struct event_pthread_t {
pthread_cond_t cond;
pthread_mutex_t mutex;
int state;
} event_pthread_t;
typedef struct thread_param
{
void (*thread_rout)(void*);
void * param;
typedef struct thread_param {
void (*thread_rout)(void *);
void *param;
} thread_param;
typedef struct pt_mutex_t
{
typedef struct pt_mutex_t {
pthread_mutex_t mutex;
} pt_mutex_t;
void *
thread_run_wrapper(thread_param* arg)
thread_run_wrapper(thread_param *arg)
{
thread_param localparam = *arg;
free(arg);
@@ -38,7 +31,6 @@ thread_run_wrapper(thread_param* arg)
return NULL;
}
thread_t *
thread_create(void (*thread_rout)(void *param), void *param)
{
@@ -47,19 +39,17 @@ thread_create(void (*thread_rout)(void *param), void *param)
thrparam->thread_rout = thread_rout;
thrparam->param = param;
pthread_create(thread, NULL, (void* (*)(void*))thread_run_wrapper, thrparam);
pthread_create(thread, NULL, (void *(*) (void *) ) thread_run_wrapper, thrparam);
return thread;
}
int
thread_wait(thread_t *arg)
{
return pthread_join(*(pthread_t*)(arg), NULL);
return pthread_join(*(pthread_t *) (arg), NULL);
}
event_t *
thread_create_event()
{
@@ -69,14 +59,13 @@ thread_create_event()
pthread_mutex_init(&event->mutex, NULL);
event->state = 0;
return (event_t *)event;
return (event_t *) event;
}
void
thread_set_event(event_t *handle)
{
event_pthread_t *event = (event_pthread_t *)handle;
event_pthread_t *event = (event_pthread_t *) handle;
pthread_mutex_lock(&event->mutex);
event->state = 1;
@@ -84,22 +73,20 @@ thread_set_event(event_t *handle)
pthread_mutex_unlock(&event->mutex);
}
void
thread_reset_event(event_t *handle)
{
event_pthread_t *event = (event_pthread_t *)handle;
event_pthread_t *event = (event_pthread_t *) handle;
pthread_mutex_lock(&event->mutex);
event->state = 0;
pthread_mutex_unlock(&event->mutex);
}
int
thread_wait_event(event_t *handle, int timeout)
{
event_pthread_t *event = (event_pthread_t *)handle;
event_pthread_t *event = (event_pthread_t *) handle;
struct timespec abstime;
clock_gettime(CLOCK_REALTIME, &abstime);
@@ -121,11 +108,10 @@ thread_wait_event(event_t *handle, int timeout)
return 0;
}
void
thread_destroy_event(event_t *handle)
{
event_pthread_t *event = (event_pthread_t *)handle;
event_pthread_t *event = (event_pthread_t *) handle;
pthread_cond_destroy(&event->cond);
pthread_mutex_destroy(&event->mutex);
@@ -133,7 +119,6 @@ thread_destroy_event(event_t *handle)
free(event);
}
mutex_t *
thread_create_mutex(void)
{
@@ -144,46 +129,40 @@ thread_create_mutex(void)
return mutex;
}
int
thread_wait_mutex(mutex_t *_mutex)
{
if (_mutex == NULL)
return(0);
pt_mutex_t *mutex = (pt_mutex_t *)_mutex;
return (0);
pt_mutex_t *mutex = (pt_mutex_t *) _mutex;
return
pthread_mutex_lock(&mutex->mutex) != 0;
return pthread_mutex_lock(&mutex->mutex) != 0;
}
int
thread_test_mutex(mutex_t *_mutex)
{
if (_mutex == NULL)
return(0);
pt_mutex_t *mutex = (pt_mutex_t *)_mutex;
return (0);
pt_mutex_t *mutex = (pt_mutex_t *) _mutex;
return
pthread_mutex_trylock(&mutex->mutex) != 0;
return pthread_mutex_trylock(&mutex->mutex) != 0;
}
int
thread_release_mutex(mutex_t *_mutex)
{
if (_mutex == NULL)
return(0);
pt_mutex_t *mutex = (pt_mutex_t *)_mutex;
return (0);
pt_mutex_t *mutex = (pt_mutex_t *) _mutex;
return pthread_mutex_unlock(&mutex->mutex) != 0;
}
void
thread_close_mutex(mutex_t *_mutex)
{
pt_mutex_t *mutex = (pt_mutex_t *)_mutex;
pt_mutex_t *mutex = (pt_mutex_t *) _mutex;
pthread_mutex_destroy(&mutex->mutex);