mirror of
https://github.com/86Box/86Box.git
synced 2026-02-22 17:45:31 -07:00
Conflict resolution.
This commit is contained in:
@@ -88,10 +88,6 @@ CMAKE_DEPENDENT_OPTION(VNC "VNC renderer" ON "DEV_BRANCH" OFF)
|
||||
CMAKE_DEPENDENT_OPTION(XL24 "ATI VGA Wonder XL24 (ATI-28800-6)" ON "DEV_BRANCH" OFF)
|
||||
CMAKE_DEPENDENT_OPTION(VECT486VL "HP Vectra 486VL" ON "DEV_BRANCH" OFF)
|
||||
|
||||
if(WIN32)
|
||||
option(PTHREAD "Use POSIX threads (pthreads) instead of Win32 threads" ON)
|
||||
endif()
|
||||
|
||||
# HACK: Avoid a MSVC2019 compiler bug on ARM64 Debug builds
|
||||
if(MSVC_TOOLSET_VERSION GREATER_EQUAL 142 AND ARCH STREQUAL "arm64")
|
||||
# Define a cache option in case somebody wants to disable this workaround
|
||||
|
||||
@@ -47,22 +47,6 @@ if(VNC)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT WIN32 OR PTHREAD)
|
||||
target_sources(86Box PRIVATE thread.c)
|
||||
if(WIN32 AND VCPKG_TOOLCHAIN)
|
||||
find_package(pthreads REQUIRED)
|
||||
if (PThreads4W_FOUND)
|
||||
target_link_libraries(86Box PThreads4W::PThreads4W)
|
||||
else()
|
||||
target_link_libraries(86Box pthreads)
|
||||
endif()
|
||||
else()
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(86Box Threads::Threads)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(86Box cpu chipset mch dev mem fdd game cdrom zip mo hdd
|
||||
net print scsi sio snd vid voodoo plat ui)
|
||||
|
||||
|
||||
@@ -8,10 +8,14 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
else()
|
||||
set(PLAT_SOURCES unix_midi.c)
|
||||
endif()
|
||||
add_library(plat STATIC ${PLAT_SOURCES})
|
||||
add_library(plat STATIC ${PLAT_SOURCES} unix_thread.c)
|
||||
add_library(ui STATIC unix.c unix_sdl.c unix_cdrom.c)
|
||||
target_compile_definitions(ui PUBLIC _FILE_OFFSET_BITS=64)
|
||||
target_link_libraries(ui dl)
|
||||
if (ALSA_FOUND)
|
||||
target_link_libraries(plat ALSA::ALSA)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(86Box Threads::Threads)
|
||||
@@ -1,191 +1,52 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#ifdef __APPLE__
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#include <inttypes.h>
|
||||
#include <86box/86box.h>
|
||||
#include <86box/plat.h>
|
||||
#if (defined WIN32) || (defined _WIN32) || (defined _WIN32)
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
|
||||
typedef struct {
|
||||
HANDLE handle;
|
||||
} win_event_t;
|
||||
|
||||
|
||||
thread_t *
|
||||
thread_create(void (*func)(void *param), void *param)
|
||||
{
|
||||
uintptr_t bt = _beginthread(func, 0, param);
|
||||
return((thread_t *)bt);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
thread_wait(thread_t *arg, int timeout)
|
||||
{
|
||||
if (arg == NULL) return(0);
|
||||
|
||||
if (timeout == -1)
|
||||
timeout = INFINITE;
|
||||
|
||||
if (WaitForSingleObject(arg, timeout)) return(1);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
event_t *
|
||||
thread_create_event(void)
|
||||
{
|
||||
win_event_t *ev = malloc(sizeof(win_event_t));
|
||||
|
||||
ev->handle = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
|
||||
return((event_t *)ev);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
thread_set_event(event_t *arg)
|
||||
{
|
||||
win_event_t *ev = (win_event_t *)arg;
|
||||
|
||||
if (arg == NULL) return;
|
||||
|
||||
SetEvent(ev->handle);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
thread_reset_event(event_t *arg)
|
||||
{
|
||||
win_event_t *ev = (win_event_t *)arg;
|
||||
|
||||
if (arg == NULL) return;
|
||||
|
||||
ResetEvent(ev->handle);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
thread_wait_event(event_t *arg, int timeout)
|
||||
{
|
||||
win_event_t *ev = (win_event_t *)arg;
|
||||
|
||||
if (arg == NULL) return(0);
|
||||
|
||||
if (ev->handle == NULL) return(0);
|
||||
|
||||
if (timeout == -1)
|
||||
timeout = INFINITE;
|
||||
|
||||
if (WaitForSingleObject(ev->handle, timeout)) return(1);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
thread_destroy_event(event_t *arg)
|
||||
{
|
||||
win_event_t *ev = (win_event_t *)arg;
|
||||
|
||||
if (arg == NULL) return;
|
||||
|
||||
CloseHandle(ev->handle);
|
||||
|
||||
free(ev);
|
||||
}
|
||||
|
||||
|
||||
mutex_t *
|
||||
thread_create_mutex(void)
|
||||
{
|
||||
mutex_t *mutex = malloc(sizeof(CRITICAL_SECTION));
|
||||
|
||||
InitializeCriticalSection(mutex);
|
||||
|
||||
return mutex;
|
||||
}
|
||||
|
||||
|
||||
mutex_t *
|
||||
thread_create_mutex_with_spin_count(unsigned int spin_count)
|
||||
{
|
||||
mutex_t *mutex = malloc(sizeof(CRITICAL_SECTION));
|
||||
|
||||
InitializeCriticalSectionAndSpinCount(mutex, spin_count);
|
||||
|
||||
return mutex;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
thread_wait_mutex(mutex_t *mutex)
|
||||
{
|
||||
if (mutex == NULL) return(0);
|
||||
|
||||
LPCRITICAL_SECTION critsec = (LPCRITICAL_SECTION)mutex;
|
||||
|
||||
EnterCriticalSection(critsec);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
thread_release_mutex(mutex_t *mutex)
|
||||
{
|
||||
if (mutex == NULL) return(0);
|
||||
|
||||
LPCRITICAL_SECTION critsec = (LPCRITICAL_SECTION)mutex;
|
||||
|
||||
LeaveCriticalSection(critsec);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
thread_close_mutex(mutex_t *mutex)
|
||||
{
|
||||
if (mutex == NULL) return;
|
||||
|
||||
LPCRITICAL_SECTION critsec = (LPCRITICAL_SECTION)mutex;
|
||||
|
||||
DeleteCriticalSection(critsec);
|
||||
|
||||
free(critsec);
|
||||
}
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
typedef struct event_pthread_t
|
||||
{
|
||||
pthread_cond_t cond;
|
||||
pthread_mutex_t mutex;
|
||||
int state;
|
||||
int state;
|
||||
} event_pthread_t;
|
||||
|
||||
|
||||
typedef struct thread_param
|
||||
{
|
||||
void (*thread_rout)(void*);
|
||||
void * param;
|
||||
} thread_param;
|
||||
|
||||
|
||||
typedef struct pt_mutex_t
|
||||
{
|
||||
pthread_mutex_t mutex;
|
||||
} pt_mutex_t;
|
||||
|
||||
|
||||
void *
|
||||
thread_run_wrapper(thread_param* arg)
|
||||
{
|
||||
thread_param localparam = *arg;
|
||||
free(arg);
|
||||
localparam.thread_rout(localparam.param);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
thread_t *
|
||||
thread_create(void (*thread_rout)(void *param), void *param)
|
||||
{
|
||||
pthread_t *thread = malloc(sizeof(pthread_t));
|
||||
thread_param *thrparam = malloc(sizeof(thread_param));
|
||||
thrparam->thread_rout = thread_rout;
|
||||
thrparam->param = param;
|
||||
|
||||
pthread_create(thread, NULL, (void*)thread_rout, param);
|
||||
pthread_create(thread, NULL, (void* (*)(void*))thread_run_wrapper, thrparam);
|
||||
|
||||
return thread;
|
||||
}
|
||||
@@ -240,13 +101,10 @@ thread_wait_event(event_t *handle, int timeout)
|
||||
event_pthread_t *event = (event_pthread_t *)handle;
|
||||
struct timespec abstime;
|
||||
|
||||
#ifdef __linux__
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
#ifdef HAS_TIMESPEC_GET
|
||||
timespec_get(&abstime, TIME_UTC);
|
||||
#else
|
||||
struct timeval now;
|
||||
gettimeofday(&now, 0);
|
||||
abstime.tv_sec = now.tv_sec;
|
||||
abstime.tv_nsec = now.tv_usec*1000UL;
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
#endif
|
||||
abstime.tv_nsec += (timeout % 1000) * 1000000;
|
||||
abstime.tv_sec += (timeout / 1000);
|
||||
@@ -301,22 +159,23 @@ thread_create_mutex_with_spin_count(unsigned int spin_count)
|
||||
int
|
||||
thread_wait_mutex(mutex_t *_mutex)
|
||||
{
|
||||
if (_mutex == NULL)
|
||||
return(0);
|
||||
pt_mutex_t *mutex = (pt_mutex_t *)_mutex;
|
||||
|
||||
pthread_mutex_lock(&mutex->mutex);
|
||||
|
||||
return 1;
|
||||
return
|
||||
pthread_mutex_lock(&mutex->mutex) != 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
thread_release_mutex(mutex_t *_mutex)
|
||||
{
|
||||
if (_mutex == NULL)
|
||||
return(0);
|
||||
pt_mutex_t *mutex = (pt_mutex_t *)_mutex;
|
||||
|
||||
pthread_mutex_unlock(&mutex->mutex);
|
||||
|
||||
return 1;
|
||||
return pthread_mutex_unlock(&mutex->mutex) != 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -329,4 +188,3 @@ thread_close_mutex(mutex_t *_mutex)
|
||||
|
||||
free(mutex);
|
||||
}
|
||||
#endif
|
||||
@@ -1847,11 +1847,11 @@ s3_hwcursor_draw(svga_t *svga, int displine)
|
||||
if (svga->crtc[0x55] & 0x10) {
|
||||
/*X11*/
|
||||
for (xx = 0; xx < 16; xx++) {
|
||||
if (offset >= svga->hwcursor_latch.x) {
|
||||
if (offset >= 0) {
|
||||
if (dat[0] & 0x8000)
|
||||
buffer32->line[displine][offset + svga->x_add] = (dat[1] & 0x8000) ? fg : bg;
|
||||
}
|
||||
|
||||
|
||||
offset++;
|
||||
dat[0] <<= shift;
|
||||
dat[1] <<= shift;
|
||||
@@ -1859,16 +1859,16 @@ s3_hwcursor_draw(svga_t *svga, int displine)
|
||||
} else {
|
||||
/*Windows*/
|
||||
for (xx = 0; xx < width; xx++) {
|
||||
if (offset >= svga->hwcursor_latch.x) {
|
||||
if (offset >= 0) {
|
||||
if (!(dat[0] & 0x8000))
|
||||
buffer32->line[displine][offset + svga->x_add] = (dat[1] & 0x8000) ? fg : bg;
|
||||
else if (dat[1] & 0x8000)
|
||||
buffer32->line[displine][offset + svga->x_add] ^= 0xffffff;
|
||||
}
|
||||
|
||||
offset++;
|
||||
dat[0] <<= shift;
|
||||
dat[1] <<= shift;
|
||||
}
|
||||
|
||||
offset++;
|
||||
dat[0] <<= shift;
|
||||
dat[1] <<= shift;
|
||||
}
|
||||
}
|
||||
svga->hwcursor_latch.addr += 4;
|
||||
|
||||
@@ -3316,7 +3316,7 @@ static void s3_virge_hwcursor_draw(svga_t *svga, int displine)
|
||||
/*X11*/
|
||||
for (xx = 0; xx < 16; xx++)
|
||||
{
|
||||
if (offset >= svga->hwcursor_latch.x)
|
||||
if (offset >= 0)
|
||||
{
|
||||
if (dat[0] & 0x8000)
|
||||
buffer32->line[displine][offset + svga->x_add] = (dat[1] & 0x8000) ? fg : bg;
|
||||
@@ -3332,7 +3332,7 @@ static void s3_virge_hwcursor_draw(svga_t *svga, int displine)
|
||||
/*Windows*/
|
||||
for (xx = 0; xx < 16; xx++)
|
||||
{
|
||||
if (offset >= svga->hwcursor_latch.x)
|
||||
if (offset >= 0)
|
||||
{
|
||||
if (!(dat[0] & 0x8000))
|
||||
buffer32->line[displine][offset + svga->x_add] = (dat[1] & 0x8000) ? fg : bg;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
enable_language(RC)
|
||||
|
||||
add_library(plat OBJECT win.c win_dynld.c win_cdrom.c
|
||||
add_library(plat OBJECT win.c win_dynld.c win_cdrom.c win_thread.c
|
||||
win_keyboard.c win_crashdump.c win_midi.c win_mouse.c)
|
||||
|
||||
add_library(ui OBJECT win_ui.c win_stbar.c win_sdl.c win_dialog.c win_about.c
|
||||
@@ -58,9 +58,5 @@ if(OPENGL)
|
||||
target_sources(ui PRIVATE glad.c win_opengl.c win_opengl_glslp.c)
|
||||
endif()
|
||||
|
||||
if(NOT PTHREAD)
|
||||
target_sources(plat PRIVATE win_thread.c)
|
||||
endif()
|
||||
|
||||
target_link_libraries(86Box advapi32 comctl32 comdlg32 gdi32 shell32 iphlpapi
|
||||
dxguid imm32 hid setupapi uxtheme version winmm psapi)
|
||||
|
||||
@@ -26,10 +26,6 @@ ifndef DEV_BUILD
|
||||
DEV_BUILD := n
|
||||
endif
|
||||
|
||||
ifneq ($(PTHREAD), n)
|
||||
PTHREAD := y
|
||||
endif
|
||||
|
||||
ifeq ($(DEV_BUILD), y)
|
||||
ifndef DEBUG
|
||||
DEBUG := y
|
||||
@@ -589,17 +585,10 @@ CXXFLAGS := $(CFLAGS)
|
||||
#########################################################################
|
||||
# Create the (final) list of objects to build. #
|
||||
#########################################################################
|
||||
ifeq ($(PTHREAD), y)
|
||||
MAINOBJ := 86box.o config.o log.o random.o timer.o io.o acpi.o apm.o dma.o ddma.o \
|
||||
nmi.o pic.o pit.o port_6x.o port_92.o ppi.o pci.o mca.o \
|
||||
usb.o device.o nvr.o nvr_at.o nvr_ps2.o thread.o \
|
||||
$(VNCOBJ)
|
||||
else
|
||||
MAINOBJ := 86box.o config.o log.o random.o timer.o io.o acpi.o apm.o dma.o ddma.o \
|
||||
nmi.o pic.o pit.o port_6x.o port_92.o ppi.o pci.o mca.o \
|
||||
usb.o device.o nvr.o nvr_at.o nvr_ps2.o \
|
||||
$(VNCOBJ)
|
||||
endif
|
||||
|
||||
MEMOBJ := catalyst_flash.o i2c_eeprom.o intel_flash.o mem.o rom.o smram.o spd.o sst_flash.o
|
||||
|
||||
@@ -801,19 +790,11 @@ VOODOOOBJ := vid_voodoo.o vid_voodoo_banshee.o \
|
||||
vid_voodoo_render.o vid_voodoo_setup.o \
|
||||
vid_voodoo_texture.o
|
||||
|
||||
ifeq ($(PTHREAD), y)
|
||||
PLATOBJ := win.o \
|
||||
win_dynld.o \
|
||||
win_cdrom.o win_keyboard.o \
|
||||
win_crashdump.o win_midi.o \
|
||||
win_mouse.o
|
||||
else
|
||||
PLATOBJ := win.o \
|
||||
win_dynld.o win_thread.o \
|
||||
win_cdrom.o win_keyboard.o \
|
||||
win_crashdump.o win_midi.o \
|
||||
win_mouse.o
|
||||
endif
|
||||
|
||||
ifeq ($(DINPUT), y)
|
||||
PLATOBJ += win_joystick.o
|
||||
@@ -839,11 +820,7 @@ endif
|
||||
ifneq ($(WX), n)
|
||||
LIBS += $(WX_LIBS) -lm
|
||||
endif
|
||||
ifeq ($(PTHREAD), y)
|
||||
LIBS += -lpng -lz -lwsock32 -lshell32 -liphlpapi -lpsapi -lSDL2 -limm32 -lhid -lsetupapi -loleaut32 -luxtheme -lversion -lwinmm -static -lstdc++ -lpthread
|
||||
else
|
||||
LIBS += -lpng -lz -lwsock32 -lshell32 -liphlpapi -lpsapi -lSDL2 -limm32 -lhid -lsetupapi -loleaut32 -luxtheme -lversion -lwinmm -static -lstdc++
|
||||
endif
|
||||
ifneq ($(X64), y)
|
||||
ifneq ($(ARM64), y)
|
||||
LIBS += -Wl,--large-address-aware
|
||||
|
||||
Reference in New Issue
Block a user