Merge commit 'da46a07b7c25996aeda2cf8b49d3b9bf2e08c46f' into mingw32

This commit is contained in:
kanjitalk755 2018-06-19 10:33:33 +09:00
commit 1cd716ee8e
13 changed files with 124 additions and 36 deletions

View File

@ -39,6 +39,8 @@
#include "ether_windows.h"
#include "router/router.h"
#include "util_windows.h"
// somehow util_windows undefines min
#define min(x,y) ((x) < (y) ? (x) : (y))
#include "libslirp.h"
// Define to let the slirp library determine the right timeout for select()

View File

@ -28,6 +28,8 @@
#include "main.h"
#include "util_windows.h"
// somehow util_windows undefines min
#define min(x,y) ((x) < (y) ? (x) : (y))
#include "macos_util.h"
#include "prefs.h"
#include "serial.h"
@ -310,12 +312,12 @@ open_error:
if (input_thread_active) {
TerminateThread(input_thread_active,0);
CloseHandle(input_signal);
input_thread_active = false;
input_thread_active = 0;
}
if (output_thread_active) {
TerminateThread(output_thread_active,0);
CloseHandle(output_signal);
output_thread_active = false;
output_thread_active = 0;
}
if(fd != INVALID_HANDLE_VALUE) {
CloseHandle(fd);
@ -674,13 +676,13 @@ int16 XSERDPort::close()
if (input_thread_active) {
quitting = true;
ReleaseSemaphore(input_signal,1,NULL);
input_thread_active = false;
input_thread_active = 0;
CloseHandle(input_signal);
}
if (output_thread_active) {
quitting = true;
ReleaseSemaphore(output_signal,1,NULL);
output_thread_active = false;
output_thread_active = 0;
// bugfix: was: CloseHandle(&output_signal);
CloseHandle(output_signal);
}

View File

@ -30,6 +30,8 @@
#include <sys/types.h>
#include <sys/timeb.h>
#include "main.h"
static inline void _cdecl vwinbug(const char *s, va_list vargs)
{
char msg[1024], date[50], hours[50];

View File

@ -2,7 +2,16 @@
#define _LIBSLIRP_H
#ifdef _WIN32
#ifdef __MINGW32__
#if _WIN32_WINNT < 0x501
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x501
#endif
#endif
#include <winsock2.h>
#ifdef __MINGW32__
#include <WS2tcpip.h>
#endif
int inet_aton(const char *cp, struct in_addr *ia);
#else
#include <sys/select.h>

View File

@ -22,8 +22,30 @@ typedef char *caddr_t;
typedef int socklen_t;
typedef unsigned long ioctlsockopt_t;
#ifdef __MINGW32__
#if _WIN32_WINNT < 0x501
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x501
#endif
#endif
# include <winsock2.h>
# include <WS2tcpip.h>
#ifdef __MINGW32__
char * WSAAPI inet_ntop(
INT Family,
PVOID pAddr,
PTSTR pStringBuf,
size_t StringBufSize
);
INT WSAAPI inet_pton(
INT Family,
const char * pszAddrString,
PVOID pAddrBuf
);
#endif
# include <sys/timeb.h>
# include <iphlpapi.h>

View File

@ -49,6 +49,8 @@ $(SRCARCHIVE): $(SRCS) $(DOCS)
# Links to Basilisk II sources
#
links:
mkdir -p src/CrossPlatform
mkdir -p src/Unix/Irix
@list='adb.cpp audio.cpp cdrom.cpp disk.cpp extfs.cpp pict.c \
prefs.cpp scsi.cpp sony.cpp xpram.cpp \
include/adb.h include/audio.h include/audio_defs.h \
@ -87,7 +89,6 @@ links:
Windows/posix_emu.cpp Windows/posix_emu.h Windows/sys_windows.cpp \
Windows/timer_windows.cpp Windows/util_windows.cpp \
Windows/util_windows.h Windows/xpram_windows.cpp \
Windows/kernel_windows.h Windows/kernel_windows.cpp \
Windows/serial_windows.cpp Windows/router Windows/b2ether \
Windows/ether_windows.h Windows/ether_windows.cpp \
Windows/serial_windows.cpp Windows/prefs_editor_gtk.cpp \
@ -98,7 +99,8 @@ links:
echo $$i; o=$$i; \
case $$i in *codegen_x86.h) o=kpx_cpu/src/cpu/jit/x86/codegen_x86.h;; esac; \
SUB=`echo $$o | sed 's;[^/]*/;../;g' | sed 's;[^/]*$$;;'` ;\
ln -sf "$$PREFIX$$SUB$(B2_TOPDIR)/src/$$i" src/$$o; \
cur_link=src/$$o ;\
if [ -d "$$cur_link" ]; then rm -rf "$$cur_link"; fi ;\
ln -sf "$$PREFIX$$SUB$(B2_TOPDIR)/src/$$i" $$cur_link; \
fi; \
done; \
ln -sf ../../../../../SheepShaver/src/Unix/config.h $(B2_TOPDIR)/src/Unix/Linux/NetDriver/config.h
done;

View File

@ -37,8 +37,9 @@ CFLAGS = @CFLAGS@ $(SDL_CFLAGS)
CXXFLAGS = @CXXFLAGS@ $(SDL_CFLAGS)
CPPFLAGS = @CPPFLAGS@ -I../include -I. -I../slirp
DEFS = @DEFS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@ -lwsock32 -liphlpapi
LDFLAGS = @LDFLAGS@ -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
#TODO remove pthread part of that if irrelevant
LIBS = @LIBS@ -lws2_32 -lwsock32 -liphlpapi
CPUSRCS = @CPUSRCS@
PERL = @PERL@
@ -54,7 +55,7 @@ HOST_CXXFLAGS = -O2
HOST_LDFLAGS =
## Files
UNIXSRCS = vm_alloc.cpp vm_alloc.h sigsegv.cpp sigsegv.h video_vosf.h video_blit.cpp video_blit.h
XPLATSRCS = vm_alloc.cpp vm_alloc.h sigsegv.cpp sigsegv.h video_vosf.h video_blit.cpp video_blit.h
ROUTERSRCS = router/arp.cpp router/dump.cpp router/dynsockets.cpp router/ftp.cpp \
router/icmp.cpp router/mib/interfaces.cpp router/iphelp.cpp router/ipsocket.cpp \
@ -69,7 +70,7 @@ SRCS = ../main.cpp main_windows.cpp ../prefs.cpp ../prefs_items.cpp prefs_window
../audio.cpp ../SDL/audio_sdl.cpp ../ether.cpp ether_windows.cpp \
../thunks.cpp ../serial.cpp serial_windows.cpp ../extfs.cpp extfs_windows.cpp \
about_window_windows.cpp ../user_strings.cpp user_strings_windows.cpp \
../dummy/prefs_editor_dummy.cpp clip_windows.cpp util_windows.cpp kernel_windows.cpp \
../dummy/prefs_editor_dummy.cpp clip_windows.cpp util_windows.cpp \
vm_alloc.cpp sigsegv.cpp posix_emu.cpp SheepShaver.rc \
$(CPUSRCS) $(ROUTERSRCS) $(SLIRP_OBJS)
@ -94,7 +95,7 @@ endif
all: $(PROGS)
$(UNIXSRCS): %: ../Unix/%
$(XPLATSRCS): %: ../CrossPlatform/%
$(LN_S) $< $@
OBJ_DIR = obj
@ -123,17 +124,17 @@ SRC_PATHS += $(sort $(foreach file, $(SRCS), $(dir $(file))))
VPATH :=
VPATH += $(addprefix :, $(subst ,:, $(filter-out $($(subst, :, ,$(VPATH))), $(SRC_PATHS))))
$(APP): $(UNIXSRCS) $(OBJ_DIR) $(OBJS)
$(APP): $(XPLATSRCS) $(OBJ_DIR) $(OBJS)
$(CXX) -o $(APP) $(LDFLAGS) $(OBJS) $(LIBS) $(SDL_LIBS)
$(UI_APP): $(UNIXSRCS) $(OBJ_DIR) $(UI_OBJS)
$(UI_APP): $(XPLATSRCS) $(OBJ_DIR) $(UI_OBJS)
$(CXX) -o $@ $(LDFLAGS) $(UI_OBJS) $(LIBS) $(GTK_LIBS) -mwindows -mno-cygwin
mostlyclean:
rm -f $(APP) $(UI_APP) $(OBJ_DIR)/* core* *.core *~ *.bak
clean: mostlyclean
rm -f $(UNIXSRCS)
rm -f $(XPLATSRCS)
rm -f dyngen basic-dyngen-ops.hpp ppc-dyngen-ops.hpp ppc-execute-impl.cpp
distclean: clean

View File

@ -14,6 +14,7 @@ AC_CANONICAL_TARGET
dnl Options.
AC_ARG_ENABLE(jit, [ --enable-jit enable JIT compiler [default=yes]], [WANT_JIT=$enableval], [WANT_JIT=yes])
AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]], [WANT_GTK=$withval], [WANT_GTK=yes])
AC_ARG_ENABLE(vosf, [ --enable-vosf enable video on SEGV signals [default=yes]], [WANT_VOSF=$enableval], [WANT_VOSF=yes])
dnl Checks for programs.
AC_PROG_CC
@ -84,7 +85,7 @@ AC_CACHE_CHECK([whether VirtualProtect works],
#define HAVE_WIN32_VM 1
#define CONFIGURE_TEST_VM_MAP
#define TEST_VM_PROT_$test_def
#include "../Unix/vm_alloc.cpp"
#include "../CrossPlatform/vm_alloc.cpp"
], ac_cv_VirtualProtect_works=no, rm -f core,
dnl When cross-compiling, assume it works
ac_cv_VirtualProtect_works="yes"
@ -94,7 +95,7 @@ AC_CACHE_CHECK([whether VirtualProtect works],
#define HAVE_WIN32_VM 1
#define CONFIGURE_TEST_VM_MAP
#define TEST_VM_PROT_RDWR_WRITE
#include "../Unix/vm_alloc.cpp"
#include "../CrossPlatform/vm_alloc.cpp"
], , ac_cv_VirtualProtect_works=no,
dnl When cross-compiling, assume it works
ac_cv_VirtualProtect_works="yes"
@ -116,8 +117,8 @@ AC_CACHE_CHECK([whether your system supports Windows exceptions],
AC_TRY_RUN([
#define HAVE_WIN32_EXCEPTIONS 1
#define CONFIGURE_TEST_SIGSEGV_RECOVERY
#include "../Unix/vm_alloc.cpp"
#include "../Unix/sigsegv.cpp"
#include "../CrossPlatform/vm_alloc.cpp"
#include "../CrossPlatform/sigsegv.cpp"
],
ac_cv_have_win32_exceptions=yes,
ac_cv_have_win32_exceptions=no,
@ -141,8 +142,8 @@ AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
AC_TRY_RUN([
#define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
#define CONFIGURE_TEST_SIGSEGV_RECOVERY
#include "../Unix/vm_alloc.cpp"
#include "../Unix/sigsegv.cpp"
#include "../CrossPlatform/vm_alloc.cpp"
#include "../CrossPlatform/sigsegv.cpp"
], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
dnl When cross-compiling, assume it works
ac_cv_have_skip_instruction="yes"
@ -153,8 +154,12 @@ AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
[Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
dnl We really want VOSF (Video on SEGV Signals) screen updates acceleration
AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
dnl Enable VOSF screen updates with this feature is requested
if [[ "x$WANT_VOSF" = "xyes" ]]; then
AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
else
WANT_VOSF=no
fi
dnl Check for GCC 2.7 or higher.
HAVE_GCC27=no
@ -262,5 +267,6 @@ echo SheepShaver configuration summary:
echo
echo Enable JIT compiler .............. : $WANT_JIT
echo GTK user interface ............... : $WANT_GTK
echo Enable VOSF ...................... : $WANT_VOSF
echo
echo "Configuration done. Now type \"make\"."

View File

@ -44,7 +44,7 @@
#include "vm_alloc.h"
#include "sigsegv.h"
#include "util_windows.h"
#include "kernel_windows.h"
//#include "kernel_windows.h"
#define DEBUG 0
#include "debug.h"
@ -207,8 +207,8 @@ int main(int argc, char **argv)
if (!check_drivers())
QuitEmulator();
// Load win32 libraries
KernelInit();
// // Load win32 libraries
// KernelInit();
// FIXME: default to DIB driver
if (getenv("SDL_VIDEODRIVER") == NULL)
@ -446,8 +446,8 @@ static void Quit(void)
// Exit preferences
PrefsExit();
// Release win32 libraries
KernelExit();
// // Release win32 libraries
// KernelExit();
#ifdef ENABLE_MON
// Exit mon

View File

@ -37,6 +37,8 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <tchar.h>
#undef _TEXT
#include <time.h>
#ifdef __WIN32__
#include <windows.h>
@ -225,6 +227,7 @@ static inline uint64 tswap64(uint64 x) { return bswap_64(x); }
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
#if defined(__GNUC__)
#if 0
#define do_byteswap_16(x) \
(__extension__ \
({ register uint16 __v, __x = (x); \
@ -243,8 +246,19 @@ static inline uint64 tswap64(uint64 x) { return bswap_64(x); }
__v = do_byteswap_32_g(__x); \
__v; }))
#else
#define do_byteswap_16(x) do_byteswap_16_g(x)
#define do_byteswap_32(x) do_byteswap_32_g(x)
inline uint16 sysdeps_inline_bswap_16(uint16 x)
{
return ((x & 0xff) << 8) | ((x >> 8) & 0xff);
}
#define do_byteswap_16(x) (sysdeps_inline_bswap_16(x))
#define do_byteswap_32(x) (do_byteswap_32_g(x))
#endif
#else
#define do_byteswap_16(x) (do_byteswap_16_g((uint16)(x)))
#define do_byteswap_32(x) (do_byteswap_32_g(x))
#endif
#if defined(__i386__) || defined(__x86_64__)

View File

@ -77,4 +77,15 @@ extern void TriggerInterrupt(void); // Trigger SIGUSR1 interrupt in emulat
extern void DisableInterrupt(void); // Disable SIGUSR1 interrupt (can be nested)
extern void EnableInterrupt(void); // Enable SIGUSR1 interrupt (can be nested)
// Array length
#if __cplusplus >= 201103L || (_MSC_VER >= 1900 && defined __cplusplus)
template <typename T, size_t size>
constexpr size_t lengthof(T (& a)[size])
{
return size;
}
#else
#define lengthof(a) (sizeof(a) / sizeof(a[0]))
#endif
#endif

View File

@ -47,8 +47,17 @@
#if HAVE_FAST_NV_MEM_FUN
#ifdef __MINGW32__
#define PF_CONVENTION __thiscall
#else
// TODO set a calling convention on other platforms/compilers where the default cc does not pass obj as first param
#define PF_CONVENTION
#endif
template< class PMF, class PF >
inline PF nv_mem_fun_of(PMF pmf) {
/** Convert member function pointer to a regular function pointer that takes the object as first parameter
*/
if (pmf == 0)
return 0;
union { PMF pmf; uintptr p[MEM_FUN_WORDS]; } x;
@ -59,7 +68,7 @@ inline PF nv_mem_fun_of(PMF pmf) {
template< class R, class T >
class nv_mem_fun_t : public std::unary_function<T, R> {
typedef R (T::*pmf_t)();
typedef R (*pf_t)(T *);
typedef R (* PF_CONVENTION pf_t)(T *);
pf_t pf;
public:
nv_mem_fun_t(pmf_t pmf) : pf(nv_mem_fun_of<pmf_t, pf_t>(pmf)) {}
@ -70,7 +79,7 @@ public:
template< class R, class T >
class const_nv_mem_fun_t : public std::unary_function<T, R> {
typedef R (T::*pmf_t)();
typedef R (*pf_t)(T *);
typedef R (* PF_CONVENTION pf_t)(T *);
pf_t const pf;
public:
const_nv_mem_fun_t(pmf_t const pmf) : pf(nv_mem_fun_of<pmf_t, pf_t>(pmf)) {}
@ -81,7 +90,7 @@ public:
template< class R, class T, class A >
class nv_mem_fun1_t : public std::binary_function<T, A, R> {
typedef R (T::*pmf_t)(A);
typedef R (*pf_t)(T *, A x);
typedef R (* PF_CONVENTION pf_t)(T *, A x);
pf_t pf;
public:
nv_mem_fun1_t(pmf_t pmf) : pf(nv_mem_fun_of<pmf_t, pf_t>(pmf)) {}
@ -92,7 +101,7 @@ public:
template< class R, class T, class A >
class const_nv_mem_fun1_t : public std::binary_function<T, A, R> {
typedef R (T::*pmf_t)(A);
typedef R (*pf_t)(T *, A x);
typedef R (* PF_CONVENTION pf_t)(T *, A x);
pf_t const pf;
public:
const_nv_mem_fun1_t(pmf_t const pmf) : pf(nv_mem_fun_of<pmf_t, pf_t>(pmf)) {}

View File

@ -894,11 +894,19 @@ void powerpc_cpu::execute_fp_int_convert(uint32 opcode)
* Rc Predicate to record CR1
**/
#ifndef FPCLASSIFY_RETURN_T
#ifdef __MINGW32__
#define FPCLASSIFY_RETURN_T int
#else
#define FPCLASSIFY_RETURN_T uint8
#endif
#endif
template< class FP >
void powerpc_cpu::fp_classify(FP x)
{
uint32 c = fpscr() & ~FPSCR_FPRF_field::mask();
uint8 fc = fpclassify(x);
FPCLASSIFY_RETURN_T fc = fpclassify(x);
switch (fc) {
case FP_NAN:
c |= FPSCR_FPRF_FU_field::mask() | FPSCR_FPRF_C_field::mask();