Merge branch 'mingw32'

This commit is contained in:
kanjitalk755 2018-06-20 19:34:06 +09:00
commit d8290af331
17 changed files with 228 additions and 128 deletions

View File

@ -40,7 +40,7 @@ CXXFLAGS = @CXXFLAGS@ $(SDL_CFLAGS)
CPPFLAGS = @CPPFLAGS@ -I../include -I. -I../CrossPlatform @CPUINCLUDES@ -I../slirp CPPFLAGS = @CPPFLAGS@ -I../include -I. -I../CrossPlatform @CPUINCLUDES@ -I../slirp
DEFS = @DEFS@ @DEFINES@ DEFS = @DEFS@ @DEFINES@
LDFLAGS = @LDFLAGS@ LDFLAGS = @LDFLAGS@
LIBS = @LIBS@ -lwsock32 -liphlpapi LIBS = @LIBS@ -lws2_32 -lwsock32 -liphlpapi
CPUSRCS = @CPUSRCS@ CPUSRCS = @CPUSRCS@
HOST_CC = gcc HOST_CC = gcc

View File

@ -131,7 +131,7 @@ AC_CACHE_CHECK([whether VirtualProtect works],
#define HAVE_WIN32_VM 1 #define HAVE_WIN32_VM 1
#define CONFIGURE_TEST_VM_MAP #define CONFIGURE_TEST_VM_MAP
#define TEST_VM_PROT_$test_def #define TEST_VM_PROT_$test_def
#include "../Unix/vm_alloc.cpp" #include "../CrossPlatform/vm_alloc.cpp"
], ac_cv_VirtualProtect_works=no, rm -f core, ], ac_cv_VirtualProtect_works=no, rm -f core,
dnl When cross-compiling, assume it works dnl When cross-compiling, assume it works
ac_cv_VirtualProtect_works="yes" ac_cv_VirtualProtect_works="yes"
@ -141,7 +141,7 @@ AC_CACHE_CHECK([whether VirtualProtect works],
#define HAVE_WIN32_VM 1 #define HAVE_WIN32_VM 1
#define CONFIGURE_TEST_VM_MAP #define CONFIGURE_TEST_VM_MAP
#define TEST_VM_PROT_RDWR_WRITE #define TEST_VM_PROT_RDWR_WRITE
#include "../Unix/vm_alloc.cpp" #include "../CrossPlatform/vm_alloc.cpp"
], , ac_cv_VirtualProtect_works=no, ], , ac_cv_VirtualProtect_works=no,
dnl When cross-compiling, assume it works dnl When cross-compiling, assume it works
ac_cv_VirtualProtect_works="yes" ac_cv_VirtualProtect_works="yes"
@ -163,8 +163,8 @@ AC_CACHE_CHECK([whether your system supports Windows exceptions],
AC_TRY_RUN([ AC_TRY_RUN([
#define HAVE_WIN32_EXCEPTIONS 1 #define HAVE_WIN32_EXCEPTIONS 1
#define CONFIGURE_TEST_SIGSEGV_RECOVERY #define CONFIGURE_TEST_SIGSEGV_RECOVERY
#include "../Unix/vm_alloc.cpp" #include "../CrossPlatform/vm_alloc.cpp"
#include "../Unix/sigsegv.cpp" #include "../CrossPlatform/sigsegv.cpp"
], ],
ac_cv_have_win32_exceptions=yes, ac_cv_have_win32_exceptions=yes,
ac_cv_have_win32_exceptions=no, ac_cv_have_win32_exceptions=no,
@ -188,8 +188,8 @@ AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
AC_TRY_RUN([ AC_TRY_RUN([
#define HAVE_SIGSEGV_SKIP_INSTRUCTION 1 #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
#define CONFIGURE_TEST_SIGSEGV_RECOVERY #define CONFIGURE_TEST_SIGSEGV_RECOVERY
#include "../Unix/vm_alloc.cpp" #include "../CrossPlatform/vm_alloc.cpp"
#include "../Unix/sigsegv.cpp" #include "../CrossPlatform/sigsegv.cpp"
], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no, ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
dnl When cross-compiling, do not assume anything. dnl When cross-compiling, do not assume anything.
ac_cv_have_skip_instruction=no ac_cv_have_skip_instruction=no

View File

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

View File

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

View File

@ -21,6 +21,10 @@
#ifndef SYSDEPS_H #ifndef SYSDEPS_H
#define SYSDEPS_H #define SYSDEPS_H
#ifdef __MINGW32__
#define _UNICODE
#endif
#if !defined _MSC_VER && !defined __STDC__ #if !defined _MSC_VER && !defined __STDC__
#error "Your compiler is not ANSI. Get a real one." #error "Your compiler is not ANSI. Get a real one."
#endif #endif
@ -318,6 +322,8 @@ static inline uae_u32 do_byteswap_16_g(uae_u32 v)
#ifdef _MSC_VER #ifdef _MSC_VER
#define ATTRIBUTE_PACKED #define ATTRIBUTE_PACKED
#else
#define ATTRIBUTE_PACKED __attribute__((__packed__))
#endif #endif
#endif #endif

View File

@ -271,7 +271,8 @@ bool check_drivers(void)
else { else {
TCHAR str[256]; TCHAR str[256];
_sntprintf(str, lengthof(str), TEXT("The CD-ROM driver file \"%s\" is missing."), path); _sntprintf(str, lengthof(str), TEXT("The CD-ROM driver file \"%s\" is missing."), path);
WarningAlert(str); //WarningAlert(str);
} }
return true; return true;

View File

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

View File

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

155
BasiliskII/src/slirp/slirp.h Executable file → Normal file
View File

@ -22,18 +22,34 @@ typedef char *caddr_t;
typedef int socklen_t; typedef int socklen_t;
typedef unsigned long ioctlsockopt_t; typedef unsigned long ioctlsockopt_t;
# include <windows.h> #ifdef __MINGW32__
#if _WIN32_WINNT < 0x501
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x501
#endif
#endif
# include <winsock2.h> # 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 <sys/timeb.h>
# include <iphlpapi.h> # include <iphlpapi.h>
# define USE_FIONBIO 1 # define USE_FIONBIO 1
# define EWOULDBLOCK WSAEWOULDBLOCK
# define EINPROGRESS WSAEINPROGRESS
# define ENOTCONN WSAENOTCONN
# define EHOSTUNREACH WSAEHOSTUNREACH
# define ENETUNREACH WSAENETUNREACH
# define ECONNREFUSED WSAECONNREFUSED
/* Basilisk II Router defines those */ /* Basilisk II Router defines those */
# define udp_read_completion slirp_udp_read_completion # define udp_read_completion slirp_udp_read_completion
@ -139,35 +155,29 @@ typedef u_int32_t uint32;
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#ifndef _P
#ifndef NO_PROTOTYPES
# define _P(x) x
#else
# define _P(x) ()
#endif
#endif
#ifdef GETTIMEOFDAY_ONE_ARG #ifdef GETTIMEOFDAY_ONE_ARG
#define gettimeofday(x, y) gettimeofday(x) #define gettimeofday(x, y) gettimeofday(x)
#endif #endif
/* Systems lacking strdup() definition in <string.h>. */ /* Systems lacking strdup() definition in <string.h>. */
#if defined(ultrix) #if defined(ultrix)
char *strdup _P((const char *)); char *strdup(const char *);
#endif #endif
/* Systems lacking malloc() definition in <stdlib.h>. */ /* Systems lacking malloc() definition in <stdlib.h>. */
#if defined(ultrix) || defined(hcx) #if defined(ultrix) || defined(hcx)
void *malloc _P((size_t arg)); void *malloc(size_t arg);
void free _P((void *ptr)); void free(void *ptr);
#endif #endif
#ifndef HAVE_INET_ATON #ifndef HAVE_INET_ATON
int inet_aton _P((const char *cp, struct in_addr *ia)); int inet_aton(const char *cp, struct in_addr *ia);
#endif #endif
#include <fcntl.h> #include <fcntl.h>
#ifdef _WIN32
#include <io.h>
#endif
#ifndef NO_UNIX_SOCKETS #ifndef NO_UNIX_SOCKETS
#include <sys/un.h> #include <sys/un.h>
#endif #endif
@ -199,11 +209,7 @@ int inet_aton _P((const char *cp, struct in_addr *ia));
#include <ppp/slirppp.h> #include <ppp/slirppp.h>
#endif #endif
#ifdef __STDC__
#include <stdarg.h> #include <stdarg.h>
#else
#include <varargs.h>
#endif
#include <sys/stat.h> #include <sys/stat.h>
@ -220,8 +226,13 @@ int inet_aton _P((const char *cp, struct in_addr *ia));
#if defined __GNUC__ #if defined __GNUC__
#define PACKED__ __attribute__ ((packed)) #define PACKED__ __attribute__ ((packed))
#elif defined _MSC_VER
#define PRAGMA_PACK_SUPPORTED 1
#define PACK_RESET
#define PACKED__
#elif defined __sgi #elif defined __sgi
#define PRAGMA_PACK_SUPPORTED 1 #define PRAGMA_PACK_SUPPORTED 1
#define PACK_RESET 0
#define PACKED__ #define PACKED__
#else #else
#error "Packed attribute or pragma shall be supported" #error "Packed attribute or pragma shall be supported"
@ -257,41 +268,49 @@ extern struct ttys *ttys_unit[MAX_INTERFACES];
#endif #endif
#ifndef FULL_BOLT #ifndef FULL_BOLT
void if_start _P((void)); void if_start(void);
#else #else
void if_start _P((struct ttys *)); void if_start(struct ttys *);
#endif #endif
#ifdef BAD_SPRINTF #ifdef BAD_SPRINTF
# define vsprintf vsprintf_len # define vsprintf vsprintf_len
# define sprintf sprintf_len # define sprintf sprintf_len
extern int vsprintf_len _P((char *, const char *, va_list)); extern int vsprintf_len(char *, const char *, va_list);
extern int sprintf_len _P((char *, const char *, ...)); extern int sprintf_len(char *, const char *, ...);
#endif #endif
#ifdef DECLARE_SPRINTF #ifdef DECLARE_SPRINTF
# ifndef BAD_SPRINTF # ifndef BAD_SPRINTF
extern int vsprintf _P((char *, const char *, va_list)); extern int vsprintf(char *, const char *, va_list);
# endif # endif
extern int vfprintf _P((FILE *, const char *, va_list)); extern int vfprintf(FILE *, const char *, va_list);
#endif #endif
#ifndef HAVE_STRERROR #ifndef HAVE_STRERROR
extern char *strerror _P((int error)); extern char *strerror(int error);
#endif #endif
#ifndef HAVE_INDEX #ifndef HAVE_INDEX
char *index _P((const char *, int)); char *index(const char *, int);
#endif #endif
#ifndef HAVE_GETHOSTID #ifndef HAVE_GETHOSTID
long gethostid _P((void)); long gethostid(void);
#endif #endif
void lprint _P((const char *, ...)); void lprint(const char *, ...);
extern int do_echo; extern int do_echo;
#if SIZEOF_CHAR_P == 4
# define insque_32 insque
# define remque_32 remque
#else
extern inline void insque_32(void *, void *);
extern inline void remque_32(void *);
#endif
#ifndef _WIN32 #ifndef _WIN32
#include <netdb.h> #include <netdb.h>
#endif #endif
@ -302,48 +321,47 @@ extern int do_echo;
int cksum(struct mbuf *m, int len); int cksum(struct mbuf *m, int len);
/* if.c */ /* if.c */
void if_init _P((void)); void if_init(void);
void if_output _P((struct socket *, struct mbuf *)); void if_output(struct socket *, struct mbuf *);
/* ip_input.c */ /* ip_input.c */
void ip_init _P((void)); void ip_init(void);
void ip_input _P((struct mbuf *)); void ip_input(struct mbuf *);
static struct ip * struct ip * ip_reass(register struct ipasfrag *, register struct ipq *);
ip_reass(register struct ip *ip, register struct ipq *); void ip_freef(struct ipq *);
void ip_freef _P((struct ipq *)); void ip_enq(register struct ipasfrag *, register struct ipasfrag *);
void ip_enq _P((register struct ipasfrag *, register struct ipasfrag *)); void ip_deq(register struct ipasfrag *);
void ip_deq _P((register struct ipasfrag *)); void ip_slowtimo(void);
void ip_slowtimo _P((void)); void ip_stripoptions(register struct mbuf *, struct mbuf *);
void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
/* ip_output.c */ /* ip_output.c */
int ip_output _P((struct socket *, struct mbuf *)); int ip_output(struct socket *, struct mbuf *);
/* tcp_input.c */ /* tcp_input.c */
int tcp_reass _P((register struct tcpcb *, register struct tcpiphdr *, struct mbuf *)); int tcp_reass(register struct tcpcb *, register struct tcpiphdr *, struct mbuf *);
void tcp_input _P((register struct mbuf *, int, struct socket *)); void tcp_input(register struct mbuf *, int, struct socket *);
void tcp_dooptions _P((struct tcpcb *, u_char *, int, struct tcpiphdr *)); void tcp_dooptions(struct tcpcb *, u_char *, int, struct tcpiphdr *);
void tcp_xmit_timer _P((register struct tcpcb *, int)); void tcp_xmit_timer(register struct tcpcb *, int);
int tcp_mss _P((register struct tcpcb *, u_int)); u_int tcp_mss(register struct tcpcb *, u_int);
/* tcp_output.c */ /* tcp_output.c */
int tcp_output _P((register struct tcpcb *)); int tcp_output(register struct tcpcb *);
void tcp_setpersist _P((register struct tcpcb *)); void tcp_setpersist(register struct tcpcb *);
/* tcp_subr.c */ /* tcp_subr.c */
void tcp_init _P((void)); void tcp_init(void);
void tcp_template _P((struct tcpcb *)); void tcp_template(struct tcpcb *);
void tcp_respond _P((struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int)); void tcp_respond(struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int);
struct tcpcb * tcp_newtcpcb _P((struct socket *)); struct tcpcb * tcp_newtcpcb(struct socket *);
struct tcpcb * tcp_close _P((register struct tcpcb *)); struct tcpcb * tcp_close(register struct tcpcb *);
void tcp_drain _P((void)); void tcp_drain(void);
void tcp_sockclosed _P((struct tcpcb *)); void tcp_sockclosed(struct tcpcb *);
int tcp_fconnect _P((struct socket *)); int tcp_fconnect(struct socket *);
void tcp_connect _P((struct socket *)); void tcp_connect(struct socket *);
int tcp_attach _P((struct socket *)); int tcp_attach(struct socket *);
u_int8_t tcp_tos _P((struct socket *)); u_int8_t tcp_tos(struct socket *);
int tcp_emu _P((struct socket *, struct mbuf *)); int tcp_emu(struct socket *, struct mbuf *);
int tcp_ctl _P((struct socket *)); int tcp_ctl(struct socket *);
struct tcpcb *tcp_drop(struct tcpcb *tp, int err); struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
#ifdef USE_PPP #ifdef USE_PPP
@ -359,9 +377,4 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
#define max(x,y) ((x) > (y) ? (x) : (y)) #define max(x,y) ((x) > (y) ? (x) : (y))
#endif #endif
#ifdef _WIN32
#undef errno
#define errno (WSAGetLastError())
#endif
#endif #endif

View File

@ -49,6 +49,7 @@ $(SRCARCHIVE): $(SRCS) $(DOCS)
# Links to Basilisk II sources # Links to Basilisk II sources
# #
links: links:
(cd src/Windows; if [ ! -e m4 ]; then ln -s ../../../BasiliskII/src/Unix/m4; fi)
@list='adb.cpp audio.cpp cdrom.cpp disk.cpp extfs.cpp pict.c \ @list='adb.cpp audio.cpp cdrom.cpp disk.cpp extfs.cpp pict.c \
prefs.cpp scsi.cpp sony.cpp xpram.cpp \ prefs.cpp scsi.cpp sony.cpp xpram.cpp \
include/adb.h include/audio.h include/audio_defs.h \ include/adb.h include/audio.h include/audio_defs.h \
@ -87,7 +88,6 @@ links:
Windows/posix_emu.cpp Windows/posix_emu.h Windows/sys_windows.cpp \ Windows/posix_emu.cpp Windows/posix_emu.h Windows/sys_windows.cpp \
Windows/timer_windows.cpp Windows/util_windows.cpp \ Windows/timer_windows.cpp Windows/util_windows.cpp \
Windows/util_windows.h Windows/xpram_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/serial_windows.cpp Windows/router Windows/b2ether \
Windows/ether_windows.h Windows/ether_windows.cpp \ Windows/ether_windows.h Windows/ether_windows.cpp \
Windows/serial_windows.cpp Windows/prefs_editor_gtk.cpp \ Windows/serial_windows.cpp Windows/prefs_editor_gtk.cpp \
@ -98,7 +98,8 @@ links:
echo $$i; o=$$i; \ echo $$i; o=$$i; \
case $$i in *codegen_x86.h) o=kpx_cpu/src/cpu/jit/x86/codegen_x86.h;; esac; \ 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;[^/]*$$;;'` ;\ 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; \ fi; \
done; \ done;
ln -sf ../../../../../SheepShaver/src/Unix/config.h $(B2_TOPDIR)/src/Unix/Linux/NetDriver/config.h

View File

@ -35,10 +35,11 @@ CC = @CC@
CXX = @CXX@ CXX = @CXX@
CFLAGS = @CFLAGS@ $(SDL_CFLAGS) CFLAGS = @CFLAGS@ $(SDL_CFLAGS)
CXXFLAGS = @CXXFLAGS@ $(SDL_CFLAGS) CXXFLAGS = @CXXFLAGS@ $(SDL_CFLAGS)
CPPFLAGS = @CPPFLAGS@ -I../include -I. -I../slirp CPPFLAGS = @CPPFLAGS@ -I../include -I. -I../slirp -I../Unix/dyngen_precompiled
DEFS = @DEFS@ DEFS = @DEFS@
LDFLAGS = @LDFLAGS@ LDFLAGS = @LDFLAGS@ -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
LIBS = @LIBS@ -lwsock32 -liphlpapi #TODO remove pthread part of that if irrelevant
LIBS = @LIBS@ -lws2_32 -lwsock32 -liphlpapi
CPUSRCS = @CPUSRCS@ CPUSRCS = @CPUSRCS@
PERL = @PERL@ PERL = @PERL@
@ -54,7 +55,7 @@ HOST_CXXFLAGS = -O2
HOST_LDFLAGS = HOST_LDFLAGS =
## Files ## 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 \ 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 \ 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 \ ../audio.cpp ../SDL/audio_sdl.cpp ../ether.cpp ether_windows.cpp \
../thunks.cpp ../serial.cpp serial_windows.cpp ../extfs.cpp extfs_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 \ 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 \ vm_alloc.cpp sigsegv.cpp posix_emu.cpp SheepShaver.rc \
$(CPUSRCS) $(ROUTERSRCS) $(SLIRP_OBJS) $(CPUSRCS) $(ROUTERSRCS) $(SLIRP_OBJS)
@ -94,7 +95,7 @@ endif
all: $(PROGS) all: $(PROGS)
$(UNIXSRCS): %: ../Unix/% $(XPLATSRCS): %: ../CrossPlatform/%
$(LN_S) $< $@ $(LN_S) $< $@
OBJ_DIR = obj OBJ_DIR = obj
@ -123,17 +124,17 @@ SRC_PATHS += $(sort $(foreach file, $(SRCS), $(dir $(file))))
VPATH := VPATH :=
VPATH += $(addprefix :, $(subst ,:, $(filter-out $($(subst, :, ,$(VPATH))), $(SRC_PATHS)))) 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) $(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 $(CXX) -o $@ $(LDFLAGS) $(UI_OBJS) $(LIBS) $(GTK_LIBS) -mwindows -mno-cygwin
mostlyclean: mostlyclean:
rm -f $(APP) $(UI_APP) $(OBJ_DIR)/* core* *.core *~ *.bak rm -f $(APP) $(UI_APP) $(OBJ_DIR)/* core* *.core *~ *.bak
clean: mostlyclean clean: mostlyclean
rm -f $(UNIXSRCS) rm -f $(XPLATSRCS)
rm -f dyngen basic-dyngen-ops.hpp ppc-dyngen-ops.hpp ppc-execute-impl.cpp rm -f dyngen basic-dyngen-ops.hpp ppc-dyngen-ops.hpp ppc-execute-impl.cpp
distclean: clean distclean: clean
@ -176,20 +177,35 @@ DYNGEN = dyngen.exe
ifeq ($(USE_DYNGEN),yes) ifeq ($(USE_DYNGEN),yes)
DYNGENDEPS = basic-dyngen-ops.hpp ppc-dyngen-ops.hpp DYNGENDEPS = basic-dyngen-ops.hpp ppc-dyngen-ops.hpp
$(DYNGEN): $(DYNGENOBJS) ###
$(HOST_CXX) -o $@ $(LDFLAGS) $(DYNGENOBJS)
$(OBJ_DIR)/basic-dyngen.o: basic-dyngen-ops.hpp basic-dyngen-ops.hpp: ../Unix/dyngen_precompiled/basic-dyngen-ops.hpp basic-dyngen-ops-x86_32.hpp basic-dyngen-ops-x86_64.hpp
$(OBJ_DIR)/basic-dyngen-ops.o: $(kpxsrcdir)/cpu/jit/basic-dyngen-ops.cpp cp -f $< $@
$(DYNGEN_CC) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) $(DYNGEN_OP_FLAGS) -c $< -o $@ basic-dyngen-ops-x86_32.hpp: ../Unix/dyngen_precompiled/basic-dyngen-ops-x86_32.hpp
basic-dyngen-ops.hpp: $(OBJ_DIR)/basic-dyngen-ops.o $(DYNGEN) cp -f $< $@
./$(DYNGEN) -o $@ $< basic-dyngen-ops-x86_64.hpp: ../Unix/dyngen_precompiled/basic-dyngen-ops-x86_64.hpp
cp -f $< $@
ppc-dyngen-ops.hpp: ../Unix/dyngen_precompiled/ppc-dyngen-ops.hpp ppc-dyngen-ops-x86_32.hpp ppc-dyngen-ops-x86_64.hpp
cp -f $< $@
ppc-dyngen-ops-x86_32.hpp: ../Unix/dyngen_precompiled/ppc-dyngen-ops-x86_32.hpp
cp -f $< $@
ppc-dyngen-ops-x86_64.hpp: ../Unix/dyngen_precompiled/ppc-dyngen-ops-x86_64.hpp
cp -f $< $@
# Only GCC is supported for generating synthetic opcodes
#$(DYNGEN): $(DYNGENOBJS)
# $(HOST_CXX) -o $@ $(LDFLAGS) $(DYNGENOBJS)
$(OBJ_DIR)/ppc-dyngen.o: ppc-dyngen-ops.hpp #$(OBJ_DIR)/basic-dyngen.o: basic-dyngen-ops.hpp
$(OBJ_DIR)/ppc-dyngen-ops.o: $(kpxsrcdir)/cpu/ppc/ppc-dyngen-ops.cpp basic-dyngen-ops.hpp #$(OBJ_DIR)/basic-dyngen-ops.o: $(kpxsrcdir)/cpu/jit/basic-dyngen-ops.cpp
$(DYNGEN_CC) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) $(DYNGEN_OP_FLAGS) -c $< -o $@ # $(DYNGEN_CC) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) $(DYNGEN_OP_FLAGS) -c $< -o $@
ppc-dyngen-ops.hpp: $(OBJ_DIR)/ppc-dyngen-ops.o $(DYNGEN) #basic-dyngen-ops.hpp: $(OBJ_DIR)/basic-dyngen-ops.o $(DYNGEN)
./$(DYNGEN) -o $@ $< # ./$(DYNGEN) -o $@ $<
#$(OBJ_DIR)/ppc-dyngen.o: ppc-dyngen-ops.hpp
#$(OBJ_DIR)/ppc-dyngen-ops.o: $(kpxsrcdir)/cpu/ppc/ppc-dyngen-ops.cpp basic-dyngen-ops.hpp
# $(DYNGEN_CC) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) $(DYNGEN_OP_FLAGS) -c $< -o $@
#ppc-dyngen-ops.hpp: $(OBJ_DIR)/ppc-dyngen-ops.o $(DYNGEN)
# ./$(DYNGEN) -o $@ $<
$(OBJ_DIR)/sheepshaver_glue.o $(OBJ_DIR)/ppc-cpu.o $(OBJ_DIR)/ppc-decode.o $(OBJ_DIR)/ppc-translate.o $(OBJ_DIR)/ppc-jit.o: basic-dyngen-ops.hpp ppc-dyngen-ops.hpp $(OBJ_DIR)/sheepshaver_glue.o $(OBJ_DIR)/ppc-cpu.o $(OBJ_DIR)/ppc-decode.o $(OBJ_DIR)/ppc-translate.o $(OBJ_DIR)/ppc-jit.o: basic-dyngen-ops.hpp ppc-dyngen-ops.hpp
endif endif

View File

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

View File

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

View File

@ -37,6 +37,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <tchar.h>
#undef _TEXT
#include <time.h> #include <time.h>
#ifdef __WIN32__ #ifdef __WIN32__
#include <windows.h> #include <windows.h>
@ -225,6 +227,7 @@ static inline uint64 tswap64(uint64 x) { return bswap_64(x); }
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
#if defined(__GNUC__) #if defined(__GNUC__)
#if 0
#define do_byteswap_16(x) \ #define do_byteswap_16(x) \
(__extension__ \ (__extension__ \
({ register uint16 __v, __x = (x); \ ({ 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 = do_byteswap_32_g(__x); \
__v; })) __v; }))
#else #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 #endif
#if defined(__i386__) || defined(__x86_64__) #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 DisableInterrupt(void); // Disable SIGUSR1 interrupt (can be nested)
extern void EnableInterrupt(void); // Enable 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 #endif

View File

@ -47,8 +47,17 @@
#if HAVE_FAST_NV_MEM_FUN #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 > template< class PMF, class PF >
inline PF nv_mem_fun_of(PMF pmf) { 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) if (pmf == 0)
return 0; return 0;
union { PMF pmf; uintptr p[MEM_FUN_WORDS]; } x; 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 > template< class R, class T >
class nv_mem_fun_t : public std::unary_function<T, R> { class nv_mem_fun_t : public std::unary_function<T, R> {
typedef R (T::*pmf_t)(); typedef R (T::*pmf_t)();
typedef R (*pf_t)(T *); typedef R (* PF_CONVENTION pf_t)(T *);
pf_t pf; pf_t pf;
public: public:
nv_mem_fun_t(pmf_t pmf) : pf(nv_mem_fun_of<pmf_t, pf_t>(pmf)) {} 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 > template< class R, class T >
class const_nv_mem_fun_t : public std::unary_function<T, R> { class const_nv_mem_fun_t : public std::unary_function<T, R> {
typedef R (T::*pmf_t)(); typedef R (T::*pmf_t)();
typedef R (*pf_t)(T *); typedef R (* PF_CONVENTION pf_t)(T *);
pf_t const pf; pf_t const pf;
public: public:
const_nv_mem_fun_t(pmf_t const pmf) : pf(nv_mem_fun_of<pmf_t, pf_t>(pmf)) {} 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 > template< class R, class T, class A >
class nv_mem_fun1_t : public std::binary_function<T, A, R> { class nv_mem_fun1_t : public std::binary_function<T, A, R> {
typedef R (T::*pmf_t)(A); 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; pf_t pf;
public: public:
nv_mem_fun1_t(pmf_t pmf) : pf(nv_mem_fun_of<pmf_t, pf_t>(pmf)) {} 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 > template< class R, class T, class A >
class const_nv_mem_fun1_t : public std::binary_function<T, A, R> { class const_nv_mem_fun1_t : public std::binary_function<T, A, R> {
typedef R (T::*pmf_t)(A); 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; pf_t const pf;
public: public:
const_nv_mem_fun1_t(pmf_t const pmf) : pf(nv_mem_fun_of<pmf_t, pf_t>(pmf)) {} 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 * 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 > template< class FP >
void powerpc_cpu::fp_classify(FP x) void powerpc_cpu::fp_classify(FP x)
{ {
uint32 c = fpscr() & ~FPSCR_FPRF_field::mask(); uint32 c = fpscr() & ~FPSCR_FPRF_field::mask();
uint8 fc = fpclassify(x); FPCLASSIFY_RETURN_T fc = fpclassify(x);
switch (fc) { switch (fc) {
case FP_NAN: case FP_NAN:
c |= FPSCR_FPRF_FU_field::mask() | FPSCR_FPRF_C_field::mask(); c |= FPSCR_FPRF_FU_field::mask() | FPSCR_FPRF_C_field::mask();