Merge pull request #145 from robxnano/unix

Restore support for various Unix OSes
This commit is contained in:
kanjitalk755 2022-10-12 10:53:39 +09:00 committed by GitHub
commit 3f7896976a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 281 additions and 398 deletions

View File

@ -274,13 +274,20 @@ static void powerpc_decode_instruction(instruction_t *instruction, unsigned int
#define SIGSEGV_REGISTER_FILE ((unsigned long *)SIGSEGV_CONTEXT_REGS), SIGSEGV_SPARC_GWINDOWS, SIGSEGV_SPARC_RWINDOW #define SIGSEGV_REGISTER_FILE ((unsigned long *)SIGSEGV_CONTEXT_REGS), SIGSEGV_SPARC_GWINDOWS, SIGSEGV_SPARC_RWINDOW
#define SIGSEGV_SKIP_INSTRUCTION sparc_skip_instruction #define SIGSEGV_SKIP_INSTRUCTION sparc_skip_instruction
#endif #endif
#if defined(__i386__) #if (defined(i386) || defined(__i386__))
#include <sys/regset.h> #include <sys/regset.h>
#define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.gregs) #define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.gregs)
#define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[EIP] #define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[EIP]
#define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS #define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS
#define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction #define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction
#endif #endif
#if (defined(x86_64) || defined(__x86_64__))
#include <sys/regset.h>
#define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.gregs)
#define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[REG_RIP]
#define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS
#define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction
#endif
#endif #endif
#if defined(__FreeBSD__) || defined(__OpenBSD__) #if defined(__FreeBSD__) || defined(__OpenBSD__)
#if (defined(i386) || defined(__i386__)) #if (defined(i386) || defined(__i386__))
@ -302,6 +309,12 @@ static void powerpc_decode_instruction(instruction_t *instruction, unsigned int
#define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[_REG_EIP] #define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[_REG_EIP]
#define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS #define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS
#define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction #define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction
#elif (defined(x86_64) || defined(__x86_64__))
#include <sys/ucontext.h>
#define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.__gregs)
#define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[_REG_RIP]
#define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS
#define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction
#endif #endif
#if (defined(powerpc) || defined(__powerpc__)) #if (defined(powerpc) || defined(__powerpc__))
#include <sys/ucontext.h> #include <sys/ucontext.h>
@ -323,12 +336,12 @@ static void powerpc_decode_instruction(instruction_t *instruction, unsigned int
#endif #endif
#if (defined(i386) || defined(__i386__)) #if (defined(i386) || defined(__i386__))
#define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.gregs) #define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.gregs)
#define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[14] /* should use REG_EIP instead */ #define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[REG_EIP]
#define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS #define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS
#define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction #define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction
#elif (defined(x86_64) || defined(__x86_64__)) #elif (defined(x86_64) || defined(__x86_64__))
#define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.gregs) #define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.gregs)
#define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[16] /* should use REG_RIP instead */ #define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[REG_RIP]
#define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS #define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS
#define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction #define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction
#elif (defined(ia64) || defined(__ia64__)) #elif (defined(ia64) || defined(__ia64__))
@ -752,38 +765,37 @@ handleExceptions(void *priv)
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION #ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
// Decode and skip X86 instruction // Decode and skip X86 instruction
#if (defined(i386) || defined(__i386__) || defined(_M_IX86)) || (defined(__x86_64__) || defined(_M_X64)) #if (defined(i386) || defined(__i386__) || defined(_M_IX86) || defined(x86_64) || defined(__x86_64__) || defined(_M_X64))
#if defined(__linux__) #if defined(__linux__)
enum { enum {
#if (defined(i386) || defined(__i386__)) #if (defined(i386) || defined(__i386__))
X86_REG_EIP = 14, X86_REG_EIP = REG_EIP,
X86_REG_EAX = 11, X86_REG_EAX = REG_EAX,
X86_REG_ECX = 10, X86_REG_ECX = REG_ECX,
X86_REG_EDX = 9, X86_REG_EDX = REG_EDX,
X86_REG_EBX = 8, X86_REG_EBX = REG_EBX,
X86_REG_ESP = 7, X86_REG_ESP = REG_ESP,
X86_REG_EBP = 6, X86_REG_EBP = REG_EBP,
X86_REG_ESI = 5, X86_REG_ESI = REG_ESI,
X86_REG_EDI = 4 X86_REG_EDI = REG_EDI
#endif #elif (defined(x86_64) || defined(__x86_64__))
#if defined(__x86_64__) X86_REG_R8 = REG_R8,
X86_REG_R8 = 0, X86_REG_R9 = REG_R9,
X86_REG_R9 = 1, X86_REG_R10 = REG_R10,
X86_REG_R10 = 2, X86_REG_R11 = REG_R11,
X86_REG_R11 = 3, X86_REG_R12 = REG_R12,
X86_REG_R12 = 4, X86_REG_R13 = REG_R13,
X86_REG_R13 = 5, X86_REG_R14 = REG_R14,
X86_REG_R14 = 6, X86_REG_R15 = REG_R15,
X86_REG_R15 = 7, X86_REG_EDI = REG_RDI,
X86_REG_EDI = 8, X86_REG_ESI = REG_RSI,
X86_REG_ESI = 9, X86_REG_EBP = REG_RBP,
X86_REG_EBP = 10, X86_REG_EBX = REG_RBX,
X86_REG_EBX = 11, X86_REG_EDX = REG_RDX,
X86_REG_EDX = 12, X86_REG_EAX = REG_RAX,
X86_REG_EAX = 13, X86_REG_ECX = REG_RCX,
X86_REG_ECX = 14, X86_REG_ESP = REG_RSP,
X86_REG_ESP = 15, X86_REG_EIP = REG_RIP
X86_REG_EIP = 16
#endif #endif
}; };
#endif #endif
@ -799,6 +811,24 @@ enum {
X86_REG_EBP = _REG_EBP, X86_REG_EBP = _REG_EBP,
X86_REG_ESI = _REG_ESI, X86_REG_ESI = _REG_ESI,
X86_REG_EDI = _REG_EDI X86_REG_EDI = _REG_EDI
#elif (defined(x86_64) || defined(__x86_64__))
X86_REG_EIP = _REG_RIP,
X86_REG_EAX = _REG_RAX,
X86_REG_ECX = _REG_RCX,
X86_REG_EDX = _REG_RDX,
X86_REG_EBX = _REG_RBX,
X86_REG_ESP = _REG_RSP,
X86_REG_EBP = _REG_RBP,
X86_REG_ESI = _REG_RSI,
X86_REG_EDI = _REG_RDI,
X86_REG_R8 = _REG_R8,
X86_REG_R9 = _REG_R9,
X86_REG_R10 = _REG_R10,
X86_REG_R11 = _REG_R11,
X86_REG_R12 = _REG_R12,
X86_REG_R13 = _REG_R13,
X86_REG_R14 = _REG_R14,
X86_REG_R15 = _REG_R15
#endif #endif
}; };
#endif #endif
@ -814,8 +844,7 @@ enum {
X86_REG_EBP = 2, X86_REG_EBP = 2,
X86_REG_ESI = 1, X86_REG_ESI = 1,
X86_REG_EDI = 0 X86_REG_EDI = 0
#endif #elif (defined(x86_64) || defined(__x86_64__))
#if (defined(x86_64) || defined(__x86_64__))
X86_REG_EDI = 0, X86_REG_EDI = 0,
X86_REG_ESI = 1, X86_REG_ESI = 1,
X86_REG_EDX = 2, X86_REG_EDX = 2,
@ -838,7 +867,7 @@ enum {
#endif #endif
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
enum { enum {
#if defined(__i386__) #if (defined(i386) || defined(__i386__))
// EDI is the first register we consider // EDI is the first register we consider
#define OREG(REG) offsetof(struct sigcontext, sc_##REG) #define OREG(REG) offsetof(struct sigcontext, sc_##REG)
#define DREG(REG) ((OREG(REG) - OREG(edi)) / 4) #define DREG(REG) ((OREG(REG) - OREG(edi)) / 4)
@ -859,7 +888,7 @@ enum {
#if defined(__sun__) #if defined(__sun__)
// Same as for Linux, need to check for x86-64 // Same as for Linux, need to check for x86-64
enum { enum {
#if defined(__i386__) #if (defined(i386) || defined(__i386__))
X86_REG_EIP = EIP, X86_REG_EIP = EIP,
X86_REG_EAX = EAX, X86_REG_EAX = EAX,
X86_REG_ECX = ECX, X86_REG_ECX = ECX,
@ -869,6 +898,24 @@ enum {
X86_REG_EBP = EBP, X86_REG_EBP = EBP,
X86_REG_ESI = ESI, X86_REG_ESI = ESI,
X86_REG_EDI = EDI X86_REG_EDI = EDI
#elif (defined(x86_64) || defined(__x86_64__))
X86_REG_R8 = REG_R8,
X86_REG_R9 = REG_R9,
X86_REG_R10 = REG_R10,
X86_REG_R11 = REG_R11,
X86_REG_R12 = REG_R12,
X86_REG_R13 = REG_R13,
X86_REG_R14 = REG_R14,
X86_REG_R15 = REG_R15,
X86_REG_EDI = EDI,
X86_REG_ESI = ESI,
X86_REG_EBP = EBP,
X86_REG_EBX = EBX,
X86_REG_EDX = EDX,
X86_REG_EAX = EAX,
X86_REG_ECX = ECX,
X86_REG_ESP = ESP,
X86_REG_EIP = REG_RIP
#endif #endif
}; };
#endif #endif
@ -3260,7 +3307,7 @@ static sigsegv_return_t sigsegv_insn_handler(sigsegv_info_t *sip)
// More sophisticated tests for instruction skipper // More sophisticated tests for instruction skipper
static bool arch_insn_skipper_tests() static bool arch_insn_skipper_tests()
{ {
#if (defined(i386) || defined(__i386__)) || (defined(__x86_64__) || defined(_M_X64)) #if (defined(i386) || defined(__i386__) || defined(x86_64) || defined(__x86_64__) || defined(_M_X64))
static const unsigned char code[] = { static const unsigned char code[] = {
0x8a, 0x00, // mov (%eax),%al 0x8a, 0x00, // mov (%eax),%al
0x8a, 0x2c, 0x18, // mov (%eax,%ebx,1),%ch 0x8a, 0x2c, 0x18, // mov (%eax,%ebx,1),%ch
@ -3274,7 +3321,7 @@ static bool arch_insn_skipper_tests()
0x8b, 0x0c, 0x18, // mov (%eax,%ebx,1),%ecx 0x8b, 0x0c, 0x18, // mov (%eax,%ebx,1),%ecx
0x89, 0x00, // mov %eax,(%eax) 0x89, 0x00, // mov %eax,(%eax)
0x89, 0x0c, 0x18, // mov %ecx,(%eax,%ebx,1) 0x89, 0x0c, 0x18, // mov %ecx,(%eax,%ebx,1)
#if defined(__x86_64__) || defined(_M_X64) #if defined(x86_64) || defined(__x86_64__) || defined(_M_X64)
0x44, 0x8a, 0x00, // mov (%rax),%r8b 0x44, 0x8a, 0x00, // mov (%rax),%r8b
0x44, 0x8a, 0x20, // mov (%rax),%r12b 0x44, 0x8a, 0x20, // mov (%rax),%r12b
0x42, 0x8a, 0x3c, 0x10, // mov (%rax,%r10,1),%dil 0x42, 0x8a, 0x3c, 0x10, // mov (%rax,%r10,1),%dil

View File

@ -71,7 +71,7 @@ typedef unsigned long vm_uintptr_t;
#ifndef MAP_32BIT #ifndef MAP_32BIT
#define MAP_32BIT 0 #define MAP_32BIT 0
#endif #endif
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__NetBSD__)
#define FORCE_MAP_32BIT MAP_FIXED #define FORCE_MAP_32BIT MAP_FIXED
#else #else
#define FORCE_MAP_32BIT MAP_32BIT #define FORCE_MAP_32BIT MAP_32BIT
@ -86,7 +86,7 @@ typedef unsigned long vm_uintptr_t;
#define MAP_EXTRA_FLAGS (MAP_32BIT) #define MAP_EXTRA_FLAGS (MAP_32BIT)
#ifdef HAVE_MMAP_VM #ifdef HAVE_MMAP_VM
#if (defined(__linux__) && defined(__i386__)) || defined(__FreeBSD__) || HAVE_LINKER_SCRIPT #if (defined(__linux__) && defined(__i386__)) || defined(__FreeBSD__) || defined(__NetBSD__) || HAVE_LINKER_SCRIPT
/* Force a reasonnable address below 0x80000000 on x86 so that we /* Force a reasonnable address below 0x80000000 on x86 so that we
don't get addresses above when the program is run on AMD64. don't get addresses above when the program is run on AMD64.
NOTE: this is empirically determined on Linux/x86. */ NOTE: this is empirically determined on Linux/x86. */

View File

@ -218,7 +218,7 @@ if [[ "x$HAVE_I386" = "xyes" ]]; then
fi fi
dnl Checks for programs. dnl Checks for programs.
AC_PROG_CC AC_PROG_CC_C99
AC_PROG_CC_C_O AC_PROG_CC_C_O
AC_PROG_CPP AC_PROG_CPP
AC_PROG_CXX AC_PROG_CXX
@ -618,6 +618,9 @@ mips-sony-bsd|mips-sony-newsos4)
*-*-freebsd*) *-*-freebsd*)
no_dev_ptmx=1 no_dev_ptmx=1
;; ;;
*-*-netbsd*)
no_dev_ptmx=1
;;
esac esac
if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes"; then if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes"; then
@ -771,8 +774,11 @@ netbsd*)
ETHERSRC=ether_unix.cpp ETHERSRC=ether_unix.cpp
;; ;;
solaris*) solaris*)
AUDIOSRC=Solaris/audio_solaris.cpp
DEFINES="$DEFINES -DBSD_COMP -D_POSIX_PTHREAD_SEMANTICS" DEFINES="$DEFINES -DBSD_COMP -D_POSIX_PTHREAD_SEMANTICS"
dnl Needed for sys/socket.h
LIBS="$LIBS -lsocket -lnsl"
dnl Needed for SDL2
CXXFLAGS="$CXXFLAGS -std=c++11"
;; ;;
irix*) irix*)
AUDIOSRC=Irix/audio_irix.cpp AUDIOSRC=Irix/audio_irix.cpp
@ -1117,6 +1123,22 @@ AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
fi dnl HAVE_MMAP_VM fi dnl HAVE_MMAP_VM
if [[ "$OS_TYPE" != "darwin" ]]; then
dnl Check if we can disable position-independent code
AC_CACHE_CHECK([whether the compiler supports -no-pie],
ac_cv_no_pie, [
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -no-pie"
AC_LINK_IFELSE([AC_LANG_PROGRAM()],[
ac_cv_no_pie="yes"],[
ac_cv_no_pie="no"
])
if [[ "$ac_cv_no_pie" = "no" ]]; then
LDFLAGS="$saved_LDFLAGS"
fi
])
fi
dnl Check if we can modify the __PAGEZERO segment for use as Low Memory dnl Check if we can modify the __PAGEZERO segment for use as Low Memory
AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x2000], AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x2000],
ac_cv_pagezero_hack, [ ac_cv_pagezero_hack, [
@ -1467,10 +1489,6 @@ if [[ "x$OS_TYPE" = "xdarwin" ]]; then
fi fi
fi fi
if [[ "x$OS_TYPE" = "xlinux" ]]; then
LDFLAGS="$LDFLAGS -no-pie"
fi
dnl Enable VOSF screen updates with this feature is requested and feasible dnl Enable VOSF screen updates with this feature is requested and feasible
if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.]) AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])

View File

@ -66,7 +66,7 @@
#include <map> #include <map>
#include <string> #include <string>
#if defined(__FreeBSD__) || defined(sgi) || (defined(__APPLE__) && defined(__MACH__)) #if defined(__FreeBSD__) || defined (__sun__) || defined(sgi) || (defined(__APPLE__) && defined(__MACH__))
#include <net/if.h> #include <net/if.h>
#endif #endif

View File

@ -414,12 +414,12 @@ static void mn_about(...)
const char *authors[] = { const char *authors[] = {
"Christian Bauer", "Christian Bauer",
"Orlando Bassotto", "Orlando Bassotto",
"Gwenolé Beauchesne", "Gwenolé Beauchesne",
"Marc Chabanas", "Marc Chabanas",
"Marc Hellwig", "Marc Hellwig",
"Biill Huey", "Biill Huey",
"Brian J. Johnson", "Brian J. Johnson",
"Jürgen Lachmann", "Jürgen Lachmann",
"Samuel Lander", "Samuel Lander",
"David Lawrence", "David Lawrence",
"Lauri Pesonen", "Lauri Pesonen",
@ -1291,7 +1291,7 @@ static GList *add_serial_names(void)
#if defined(__linux__) #if defined(__linux__)
if (strncmp(de->d_name, "ttyS", 4) == 0 || strncmp(de->d_name, "lp", 2) == 0) { if (strncmp(de->d_name, "ttyS", 4) == 0 || strncmp(de->d_name, "lp", 2) == 0) {
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
if (strncmp(de->d_name, "cuaa", 4) == 0 || strncmp(de->d_name, "lpt", 3) == 0) { if (strncmp(de->d_name, "cua", 3) == 0 || strncmp(de->d_name, "lpt", 3) == 0) {
#elif defined(__NetBSD__) #elif defined(__NetBSD__)
if (strncmp(de->d_name, "tty0", 4) == 0 || strncmp(de->d_name, "lpt", 3) == 0) { if (strncmp(de->d_name, "tty0", 4) == 0 || strncmp(de->d_name, "lpt", 3) == 0) {
#elif defined(sgi) #elif defined(sgi)

View File

@ -1,7 +1,7 @@
/* /*
* prefs_unix.cpp - Preferences handling, Unix specific stuff * prefs_unix.cpp - Preferences handling, Unix specific stuff
* *
* Basilisk II (C) 1997-2008 Christian Bauer * Basilisk II, SheepShaver (C) 1997-2008 Christian Bauer and Marc Hellwig
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -20,6 +20,7 @@
#include "sysdeps.h" #include "sysdeps.h"
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h>
#include <string> #include <string>
using std::string; using std::string;
@ -27,7 +28,16 @@ using std::string;
// Platform-specific preferences items // Platform-specific preferences items
prefs_desc platform_prefs_items[] = { prefs_desc platform_prefs_items[] = {
#ifdef SHEEPSHAVER
{"ether", TYPE_STRING, false, "device name of Mac ethernet adapter"},
{"etherconfig", TYPE_STRING, false, "path of network config script"},
{"keycodes", TYPE_BOOLEAN, false, "use keycodes rather than keysyms to decode keyboard"},
{"keycodefile", TYPE_STRING, false, "path of keycode translation file"},
{"mousewheelmode", TYPE_INT32, false, "mouse wheel support mode (0=page up/down, 1=cursor up/down)"},
{"mousewheellines", TYPE_INT32, false, "number of lines to scroll in mouse wheel mode 1"},
#else
{"fbdevicefile", TYPE_STRING, false, "path of frame buffer device specification file"}, {"fbdevicefile", TYPE_STRING, false, "path of frame buffer device specification file"},
#endif
{"dsp", TYPE_STRING, false, "audio output (dsp) device name"}, {"dsp", TYPE_STRING, false, "audio output (dsp) device name"},
{"mixer", TYPE_STRING, false, "audio mixer device name"}, {"mixer", TYPE_STRING, false, "audio mixer device name"},
{"idlewait", TYPE_BOOLEAN, false, "sleep when idle"}, {"idlewait", TYPE_BOOLEAN, false, "sleep when idle"},
@ -38,11 +48,19 @@ prefs_desc platform_prefs_items[] = {
}; };
// Standard file names and paths // Standard file names and paths
#ifdef SHEEPSHAVER
static const char PREFS_FILE_NAME[] = "/.sheepshaver_prefs";
static const char XDG_PREFS_FILE_NAME[] = "/prefs";
static const char XPRAM_FILE_NAME[] = "/.sheepshaver_nvram";
static const char XDG_XPRAM_FILE_NAME[] = "/nvram";
static const char XDG_CONFIG_SUBDIR[] = "/SheepShaver";
#else
static const char PREFS_FILE_NAME[] = "/.basilisk_ii_prefs"; static const char PREFS_FILE_NAME[] = "/.basilisk_ii_prefs";
static const char XDG_PREFS_FILE_NAME[] = "/prefs"; static const char XDG_PREFS_FILE_NAME[] = "/prefs";
static const char XPRAM_FILE_NAME[] = "/.basilisk_ii_xpram"; static const char XPRAM_FILE_NAME[] = "/.basilisk_ii_xpram";
static const char XDG_XPRAM_FILE_NAME[] = "/xpram"; static const char XDG_XPRAM_FILE_NAME[] = "/xpram";
static const char XDG_CONFIG_SUBDIR[] = "/BasiliskII"; static const char XDG_CONFIG_SUBDIR[] = "/BasiliskII";
#endif
// Prefs file name and path // Prefs file name and path
string UserPrefsPath; string UserPrefsPath;
@ -87,8 +105,8 @@ static void exit_if_dir(const string& path)
} }
if ((info.st_mode & S_IFDIR) != 0) if ((info.st_mode & S_IFDIR) != 0)
{ {
fprintf(stderr, "ERROR: Cannot open %s (Is a directory)\n", prefs_name.c_str()); fprintf(stderr, "ERROR: Cannot open %s (Is a directory)\n", prefs_name.c_str());
exit(1); exit(1);
} }
} }
@ -119,6 +137,7 @@ static bool load_prefs_file(const string& path, bool exit_on_failure)
* 3. From $HOME/.basilisk_ii_prefs if it exists * 3. From $HOME/.basilisk_ii_prefs if it exists
* 4. From $XDG_CONFIG_HOME/BasiliskII/prefs if it exists * 4. From $XDG_CONFIG_HOME/BasiliskII/prefs if it exists
* 5. Create a new prefs file at $XDG_CONFIG_HOME/BasiliskII/prefs * 5. Create a new prefs file at $XDG_CONFIG_HOME/BasiliskII/prefs
* (or the equivalent paths for SheepShaver)
* If $XDG_CONFIG_HOME doesn't exist, $HOME/.config is used instead, * If $XDG_CONFIG_HOME doesn't exist, $HOME/.config is used instead,
* in accordance with XDG Base Directory Specification: * in accordance with XDG Base Directory Specification:
* https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html * https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
@ -135,7 +154,7 @@ void LoadPrefs(const char* vmdir)
prefs_name = string(vmdir) + XDG_PREFS_FILE_NAME; prefs_name = string(vmdir) + XDG_PREFS_FILE_NAME;
xpram_name = string(vmdir) + XDG_XPRAM_FILE_NAME; xpram_name = string(vmdir) + XDG_XPRAM_FILE_NAME;
if (load_prefs_file(prefs_name, true)) if (load_prefs_file(prefs_name, true))
return; return;
} }
// --config was specified // --config was specified
@ -144,7 +163,7 @@ void LoadPrefs(const char* vmdir)
prefs_name = UserPrefsPath; prefs_name = UserPrefsPath;
xpram_name = get_dir(&prefs_name) + XPRAM_FILE_NAME; xpram_name = get_dir(&prefs_name) + XPRAM_FILE_NAME;
if (load_prefs_file(prefs_name, true)) if (load_prefs_file(prefs_name, true))
return; return;
} }
// Load .basilisk_ii_prefs from $HOME if it exists // Load .basilisk_ii_prefs from $HOME if it exists
@ -153,7 +172,7 @@ void LoadPrefs(const char* vmdir)
prefs_name = home_dir + PREFS_FILE_NAME; prefs_name = home_dir + PREFS_FILE_NAME;
xpram_name = home_dir + XPRAM_FILE_NAME; xpram_name = home_dir + XPRAM_FILE_NAME;
if (load_prefs_file(prefs_name, false)) if (load_prefs_file(prefs_name, false))
return; return;
} }
// If no other prefs file exists, try the $XDG_CONFIG_HOME directory // If no other prefs file exists, try the $XDG_CONFIG_HOME directory
@ -162,7 +181,7 @@ void LoadPrefs(const char* vmdir)
prefs_name = xdg_config_dir + XDG_PREFS_FILE_NAME; prefs_name = xdg_config_dir + XDG_PREFS_FILE_NAME;
xpram_name = xdg_config_dir + XDG_XPRAM_FILE_NAME; xpram_name = xdg_config_dir + XDG_XPRAM_FILE_NAME;
if (load_prefs_file(prefs_name, false)) if (load_prefs_file(prefs_name, false))
return; return;
} }
// No prefs file, save defaults in $XDG_CONFIG_HOME directory // No prefs file, save defaults in $XDG_CONFIG_HOME directory
@ -259,6 +278,9 @@ void AddPlatformPrefsDefaults(void)
{ {
PrefsReplaceString("mixer", "/dev/mixer"); PrefsReplaceString("mixer", "/dev/mixer");
} }
#elif defined (__NetBSD__)
PrefsReplaceString("dsp", "/dev/audio");
PrefsReplaceString("mixer", "/dev/mixer");
#else #else
PrefsReplaceString("dsp", "/dev/dsp"); PrefsReplaceString("dsp", "/dev/dsp");
PrefsReplaceString("mixer", "/dev/mixer"); PrefsReplaceString("mixer", "/dev/mixer");

View File

@ -21,12 +21,18 @@
#include "sysdeps.h" #include "sysdeps.h"
#include <sys/ioctl.h> #include <sys/ioctl.h>
#ifdef HAVE_SYS_FILIO_H
#include <sys/filio.h>
#endif
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <pthread.h> #include <pthread.h>
#include <semaphore.h> #include <semaphore.h>
#include <termios.h> #include <termios.h>
#include <errno.h> #include <errno.h>
#ifdef __linux__ #ifdef __linux__
#include <linux/lp.h> #include <linux/lp.h>
#include <linux/major.h> #include <linux/major.h>

View File

@ -22,6 +22,11 @@ RCSID("$OpenBSD: sshpty.c,v 1.4 2001/12/19 07:18:56 deraadt Exp $");
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> /* For O_NONBLOCK */ #include <fcntl.h> /* For O_NONBLOCK */
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <pwd.h> #include <pwd.h>
@ -45,10 +50,6 @@ RCSID("$OpenBSD: sshpty.c,v 1.4 2001/12/19 07:18:56 deraadt Exp $");
# include <sys/bsdtty.h> # include <sys/bsdtty.h>
#endif #endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h> /* For S_* constants and macros */
#endif
#ifndef _PATH_TTY #ifndef _PATH_TTY
# define _PATH_TTY "/dev/tty" # define _PATH_TTY "/dev/tty"
#endif #endif
@ -73,7 +74,12 @@ RCSID("$OpenBSD: sshpty.c,v 1.4 2001/12/19 07:18:56 deraadt Exp $");
#define fatal(x) do { printf("Fatal error: %s", x); return 0; } while(0) #define fatal(x) do { printf("Fatal error: %s", x); return 0; } while(0)
#endif /* not in BasiliskII */ #endif /* not in BasiliskII */
#ifdef __sun__
#define mysig_t sig_atomic_t
#else
#define mysig_t sig_t #define mysig_t sig_t
#endif
#define mysignal signal #define mysignal signal
#include <signal.h> #include <signal.h>

View File

@ -369,6 +369,9 @@ void SysAddCDROMPrefs(void)
closedir(cd_dir); closedir(cd_dir);
} }
} }
#elif defined __FreeBSD__
if (access("/cdrom", F_OK) == 0)
PrefsAddString("cdrom", "/cdrom");
#elif defined __MACOSX__ #elif defined __MACOSX__
// There is no predefined path for CD-ROMs on MacOS X. Rather, we // There is no predefined path for CD-ROMs on MacOS X. Rather, we
// define a single fake CD-ROM entry for the emulated MacOS. // define a single fake CD-ROM entry for the emulated MacOS.
@ -396,8 +399,8 @@ void SysAddSerialPrefs(void)
PrefsAddString("serialb", "/dev/tts/1"); PrefsAddString("serialb", "/dev/tts/1");
} }
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
PrefsAddString("seriala", "/dev/cuaa0"); PrefsAddString("seriala", "/dev/cuau0");
PrefsAddString("serialb", "/dev/cuaa1"); PrefsAddString("serialb", "/dev/cuau1");
#elif defined(__NetBSD__) #elif defined(__NetBSD__)
PrefsAddString("seriala", "/dev/tty00"); PrefsAddString("seriala", "/dev/tty00");
PrefsAddString("serialb", "/dev/tty01"); PrefsAddString("serialb", "/dev/tty01");

View File

@ -42,6 +42,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h>
#ifdef HAVE_PTHREADS #ifdef HAVE_PTHREADS
# include <pthread.h> # include <pthread.h>
@ -51,6 +52,10 @@
# include <fcntl.h> # include <fcntl.h>
#endif #endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h> /* For S_* constants and macros */
#endif
#ifdef TIME_WITH_SYS_TIME #ifdef TIME_WITH_SYS_TIME
# include <sys/time.h> # include <sys/time.h>
# include <time.h> # include <time.h>
@ -117,11 +122,6 @@
#ifdef HAVE_PTHREADS #ifdef HAVE_PTHREADS
#define USE_PTHREADS_SERVICES #define USE_PTHREADS_SERVICES
#endif #endif
#if EMULATED_68K
#if defined(__NetBSD__)
#define USE_CPU_EMUL_SERVICES
#endif
#endif
#ifdef USE_CPU_EMUL_SERVICES #ifdef USE_CPU_EMUL_SERVICES
#undef USE_PTHREADS_SERVICES #undef USE_PTHREADS_SERVICES
#endif #endif

View File

@ -41,11 +41,6 @@ void LoadXPRAM(const char* vmdir)
read(fd, XPRAM, XPRAM_SIZE); read(fd, XPRAM, XPRAM_SIZE);
close(fd); close(fd);
} }
else
{
fprintf(stderr, "WARNING: Unable to load %s (%s)\n",
xpram_name.c_str(), strerror(errno));
}
} }
/* /*

View File

@ -68,7 +68,7 @@ links:
Unix/vhd_unix.cpp \ Unix/vhd_unix.cpp \
Unix/extfs_unix.cpp Unix/serial_unix.cpp \ Unix/extfs_unix.cpp Unix/serial_unix.cpp \
Unix/sshpty.h Unix/sshpty.c Unix/strlcpy.h Unix/strlcpy.c \ Unix/sshpty.h Unix/sshpty.c Unix/strlcpy.h Unix/strlcpy.c \
Unix/sys_unix.cpp Unix/timer_unix.cpp Unix/xpram_unix.cpp \ Unix/sys_unix.cpp Unix/timer_unix.cpp Unix/xpram_unix.cpp Unix/prefs_unix.cpp \
Unix/semaphore.h Unix/posix_sem.cpp Unix/config.sub Unix/config.guess Unix/m4 \ Unix/semaphore.h Unix/posix_sem.cpp Unix/config.sub Unix/config.guess Unix/m4 \
Unix/keycodes Unix/tunconfig Unix/clip_unix.cpp Unix/Irix/audio_irix.cpp \ Unix/keycodes Unix/tunconfig Unix/clip_unix.cpp Unix/Irix/audio_irix.cpp \
Unix/Linux/scsi_linux.cpp Unix/Linux/NetDriver Unix/ether_unix.cpp \ Unix/Linux/scsi_linux.cpp Unix/Linux/NetDriver Unix/ether_unix.cpp \

View File

@ -255,7 +255,7 @@ static void powerpc_decode_instruction(instruction_t *instruction, unsigned int
#define SIGSEGV_FAULT_ADDRESS sip->si_addr #define SIGSEGV_FAULT_ADDRESS sip->si_addr
#if (defined(sgi) || defined(__sgi)) #if (defined(sgi) || defined(__sgi))
#include <ucontext.h> #include <ucontext.h>
#define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.gregs) #define SIGSEGV_CONTEXT_REGS (((ucontext_t*)scp)->uc_mcontext.gregs)
#define SIGSEGV_FAULT_INSTRUCTION (unsigned long)SIGSEGV_CONTEXT_REGS[CTX_EPC] #define SIGSEGV_FAULT_INSTRUCTION (unsigned long)SIGSEGV_CONTEXT_REGS[CTX_EPC]
#if (defined(mips) || defined(__mips)) #if (defined(mips) || defined(__mips))
#define SIGSEGV_REGISTER_FILE &SIGSEGV_CONTEXT_REGS[CTX_EPC], &SIGSEGV_CONTEXT_REGS[CTX_R0] #define SIGSEGV_REGISTER_FILE &SIGSEGV_CONTEXT_REGS[CTX_EPC], &SIGSEGV_CONTEXT_REGS[CTX_R0]
@ -274,13 +274,20 @@ static void powerpc_decode_instruction(instruction_t *instruction, unsigned int
#define SIGSEGV_REGISTER_FILE ((unsigned long *)SIGSEGV_CONTEXT_REGS), SIGSEGV_SPARC_GWINDOWS, SIGSEGV_SPARC_RWINDOW #define SIGSEGV_REGISTER_FILE ((unsigned long *)SIGSEGV_CONTEXT_REGS), SIGSEGV_SPARC_GWINDOWS, SIGSEGV_SPARC_RWINDOW
#define SIGSEGV_SKIP_INSTRUCTION sparc_skip_instruction #define SIGSEGV_SKIP_INSTRUCTION sparc_skip_instruction
#endif #endif
#if defined(__i386__) #if (defined(i386) || defined(__i386__))
#include <sys/regset.h> #include <sys/regset.h>
#define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.gregs) #define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.gregs)
#define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[EIP] #define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[EIP]
#define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS #define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS
#define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction #define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction
#endif #endif
#if (defined(x86_64) || defined(__x86_64__))
#include <sys/regset.h>
#define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.gregs)
#define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[REG_RIP]
#define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS
#define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction
#endif
#endif #endif
#if defined(__FreeBSD__) || defined(__OpenBSD__) #if defined(__FreeBSD__) || defined(__OpenBSD__)
#if (defined(i386) || defined(__i386__)) #if (defined(i386) || defined(__i386__))
@ -302,6 +309,12 @@ static void powerpc_decode_instruction(instruction_t *instruction, unsigned int
#define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[_REG_EIP] #define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[_REG_EIP]
#define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS #define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS
#define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction #define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction
#elif (defined(x86_64) || defined(__x86_64__))
#include <sys/ucontext.h>
#define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.__gregs)
#define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[_REG_RIP]
#define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS
#define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction
#endif #endif
#if (defined(powerpc) || defined(__powerpc__)) #if (defined(powerpc) || defined(__powerpc__))
#include <sys/ucontext.h> #include <sys/ucontext.h>
@ -323,12 +336,12 @@ static void powerpc_decode_instruction(instruction_t *instruction, unsigned int
#endif #endif
#if (defined(i386) || defined(__i386__)) #if (defined(i386) || defined(__i386__))
#define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.gregs) #define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.gregs)
#define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[14] /* should use REG_EIP instead */ #define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[REG_EIP]
#define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS #define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS
#define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction #define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction
#elif (defined(x86_64) || defined(__x86_64__)) #elif (defined(x86_64) || defined(__x86_64__))
#define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.gregs) #define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext.gregs)
#define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[16] /* should use REG_RIP instead */ #define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[REG_RIP]
#define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS #define SIGSEGV_REGISTER_FILE (SIGSEGV_REGISTER_TYPE *)SIGSEGV_CONTEXT_REGS
#define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction #define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction
#elif (defined(ia64) || defined(__ia64__)) #elif (defined(ia64) || defined(__ia64__))
@ -752,38 +765,37 @@ handleExceptions(void *priv)
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION #ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
// Decode and skip X86 instruction // Decode and skip X86 instruction
#if (defined(i386) || defined(__i386__) || defined(_M_IX86)) || (defined(__x86_64__) || defined(_M_X64)) #if (defined(i386) || defined(__i386__) || defined(_M_IX86) || defined(x86_64) || defined(__x86_64__) || defined(_M_X64))
#if defined(__linux__) #if defined(__linux__)
enum { enum {
#if (defined(i386) || defined(__i386__)) #if (defined(i386) || defined(__i386__))
X86_REG_EIP = 14, X86_REG_EIP = REG_EIP,
X86_REG_EAX = 11, X86_REG_EAX = REG_EAX,
X86_REG_ECX = 10, X86_REG_ECX = REG_ECX,
X86_REG_EDX = 9, X86_REG_EDX = REG_EDX,
X86_REG_EBX = 8, X86_REG_EBX = REG_EBX,
X86_REG_ESP = 7, X86_REG_ESP = REG_ESP,
X86_REG_EBP = 6, X86_REG_EBP = REG_EBP,
X86_REG_ESI = 5, X86_REG_ESI = REG_ESI,
X86_REG_EDI = 4 X86_REG_EDI = REG_EDI
#endif #elif (defined(x86_64) || defined(__x86_64__))
#if defined(__x86_64__) X86_REG_R8 = REG_R8,
X86_REG_R8 = 0, X86_REG_R9 = REG_R9,
X86_REG_R9 = 1, X86_REG_R10 = REG_R10,
X86_REG_R10 = 2, X86_REG_R11 = REG_R11,
X86_REG_R11 = 3, X86_REG_R12 = REG_R12,
X86_REG_R12 = 4, X86_REG_R13 = REG_R13,
X86_REG_R13 = 5, X86_REG_R14 = REG_R14,
X86_REG_R14 = 6, X86_REG_R15 = REG_R15,
X86_REG_R15 = 7, X86_REG_EDI = REG_RDI,
X86_REG_EDI = 8, X86_REG_ESI = REG_RSI,
X86_REG_ESI = 9, X86_REG_EBP = REG_RBP,
X86_REG_EBP = 10, X86_REG_EBX = REG_RBX,
X86_REG_EBX = 11, X86_REG_EDX = REG_RDX,
X86_REG_EDX = 12, X86_REG_EAX = REG_RAX,
X86_REG_EAX = 13, X86_REG_ECX = REG_RCX,
X86_REG_ECX = 14, X86_REG_ESP = REG_RSP,
X86_REG_ESP = 15, X86_REG_EIP = REG_RIP
X86_REG_EIP = 16
#endif #endif
}; };
#endif #endif
@ -799,6 +811,24 @@ enum {
X86_REG_EBP = _REG_EBP, X86_REG_EBP = _REG_EBP,
X86_REG_ESI = _REG_ESI, X86_REG_ESI = _REG_ESI,
X86_REG_EDI = _REG_EDI X86_REG_EDI = _REG_EDI
#elif (defined(x86_64) || defined(__x86_64__))
X86_REG_EIP = _REG_RIP,
X86_REG_EAX = _REG_RAX,
X86_REG_ECX = _REG_RCX,
X86_REG_EDX = _REG_RDX,
X86_REG_EBX = _REG_RBX,
X86_REG_ESP = _REG_RSP,
X86_REG_EBP = _REG_RBP,
X86_REG_ESI = _REG_RSI,
X86_REG_EDI = _REG_RDI,
X86_REG_R8 = _REG_R8,
X86_REG_R9 = _REG_R9,
X86_REG_R10 = _REG_R10,
X86_REG_R11 = _REG_R11,
X86_REG_R12 = _REG_R12,
X86_REG_R13 = _REG_R13,
X86_REG_R14 = _REG_R14,
X86_REG_R15 = _REG_R15
#endif #endif
}; };
#endif #endif
@ -814,8 +844,7 @@ enum {
X86_REG_EBP = 2, X86_REG_EBP = 2,
X86_REG_ESI = 1, X86_REG_ESI = 1,
X86_REG_EDI = 0 X86_REG_EDI = 0
#endif #elif (defined(x86_64) || defined(__x86_64__))
#if (defined(x86_64) || defined(__x86_64__))
X86_REG_EDI = 0, X86_REG_EDI = 0,
X86_REG_ESI = 1, X86_REG_ESI = 1,
X86_REG_EDX = 2, X86_REG_EDX = 2,
@ -838,7 +867,7 @@ enum {
#endif #endif
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
enum { enum {
#if defined(__i386__) #if (defined(i386) || defined(__i386__))
// EDI is the first register we consider // EDI is the first register we consider
#define OREG(REG) offsetof(struct sigcontext, sc_##REG) #define OREG(REG) offsetof(struct sigcontext, sc_##REG)
#define DREG(REG) ((OREG(REG) - OREG(edi)) / 4) #define DREG(REG) ((OREG(REG) - OREG(edi)) / 4)
@ -859,7 +888,7 @@ enum {
#if defined(__sun__) #if defined(__sun__)
// Same as for Linux, need to check for x86-64 // Same as for Linux, need to check for x86-64
enum { enum {
#if defined(__i386__) #if (defined(i386) || defined(__i386__))
X86_REG_EIP = EIP, X86_REG_EIP = EIP,
X86_REG_EAX = EAX, X86_REG_EAX = EAX,
X86_REG_ECX = ECX, X86_REG_ECX = ECX,
@ -869,6 +898,24 @@ enum {
X86_REG_EBP = EBP, X86_REG_EBP = EBP,
X86_REG_ESI = ESI, X86_REG_ESI = ESI,
X86_REG_EDI = EDI X86_REG_EDI = EDI
#elif (defined(x86_64) || defined(__x86_64__))
X86_REG_R8 = REG_R8,
X86_REG_R9 = REG_R9,
X86_REG_R10 = REG_R10,
X86_REG_R11 = REG_R11,
X86_REG_R12 = REG_R12,
X86_REG_R13 = REG_R13,
X86_REG_R14 = REG_R14,
X86_REG_R15 = REG_R15,
X86_REG_EDI = EDI,
X86_REG_ESI = ESI,
X86_REG_EBP = EBP,
X86_REG_EBX = EBX,
X86_REG_EDX = EDX,
X86_REG_EAX = EAX,
X86_REG_ECX = ECX,
X86_REG_ESP = ESP,
X86_REG_EIP = REG_RIP
#endif #endif
}; };
#endif #endif
@ -3345,7 +3392,7 @@ static sigsegv_return_t sigsegv_insn_handler(sigsegv_info_t *sip)
// More sophisticated tests for instruction skipper // More sophisticated tests for instruction skipper
static bool arch_insn_skipper_tests() static bool arch_insn_skipper_tests()
{ {
#if (defined(i386) || defined(__i386__)) || (defined(__x86_64__) || defined(_M_X64)) #if (defined(i386) || defined(__i386__) || defined(x86_64) || defined(__x86_64__) || defined(_M_X64))
static const unsigned char code[] = { static const unsigned char code[] = {
0x8a, 0x00, // mov (%eax),%al 0x8a, 0x00, // mov (%eax),%al
0x8a, 0x2c, 0x18, // mov (%eax,%ebx,1),%ch 0x8a, 0x2c, 0x18, // mov (%eax,%ebx,1),%ch
@ -3359,7 +3406,7 @@ static bool arch_insn_skipper_tests()
0x8b, 0x0c, 0x18, // mov (%eax,%ebx,1),%ecx 0x8b, 0x0c, 0x18, // mov (%eax,%ebx,1),%ecx
0x89, 0x00, // mov %eax,(%eax) 0x89, 0x00, // mov %eax,(%eax)
0x89, 0x0c, 0x18, // mov %ecx,(%eax,%ebx,1) 0x89, 0x0c, 0x18, // mov %ecx,(%eax,%ebx,1)
#if defined(__x86_64__) || defined(_M_X64) #if defined(x86_64) || defined(__x86_64__) || defined(_M_X64)
0x44, 0x8a, 0x00, // mov (%rax),%r8b 0x44, 0x8a, 0x00, // mov (%rax),%r8b
0x44, 0x8a, 0x20, // mov (%rax),%r12b 0x44, 0x8a, 0x20, // mov (%rax),%r12b
0x42, 0x8a, 0x3c, 0x10, // mov (%rax,%r10,1),%dil 0x42, 0x8a, 0x3c, 0x10, // mov (%rax,%r10,1),%dil

View File

@ -46,7 +46,7 @@ AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [d
esac], esac],
[WANT_GTK="gtk2 gtk"]) [WANT_GTK="gtk2 gtk"])
AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=no]) AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=no])
AC_ARG_WITH(dgcc, [ --with-dgcc=COMPILER use C++ COMPILER to compile synthetic opcodes or 'precompiled'], [DYNGEN_CC=$withval]) AC_ARG_WITH(dgcc, [ --with-dgcc=COMPILER use C++ COMPILER to compile synthetic opcodes or 'precompiled'], [DYNGEN_CC=$withval], [DYNGEN_CC=precompiled])
AC_ARG_WITH(bincue, AC_ARG_WITH(bincue,
AS_HELP_STRING([--with-bincue], [Allow cdrom image files in bin/cue mode])) AS_HELP_STRING([--with-bincue], [Allow cdrom image files in bin/cue mode]))
@ -75,7 +75,7 @@ AC_ARG_ENABLE(sdl-framework-prefix, [ --enable-sdl-framework-prefix=PFX d
AC_ARG_WITH(sdl1, [ --with-sdl1 use SDL 1.x, rather than SDL 2.x [default=no]], [WANT_SDL_VERSION_MAJOR=1], []) AC_ARG_WITH(sdl1, [ --with-sdl1 use SDL 1.x, rather than SDL 2.x [default=no]], [WANT_SDL_VERSION_MAJOR=1], [])
dnl Checks for programs. dnl Checks for programs.
AC_PROG_CC AC_PROG_CC_C99
AC_PROG_CPP AC_PROG_CPP
AC_PROG_CXX AC_PROG_CXX
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
@ -525,6 +525,9 @@ mips-sony-bsd|mips-sony-newsos4)
*-*-freebsd*) *-*-freebsd*)
no_dev_ptmx=1 no_dev_ptmx=1
;; ;;
*-*-netbsd*)
no_dev_ptmx=1
;;
esac esac
if test -z "$no_dev_ptmx" ; then if test -z "$no_dev_ptmx" ; then
@ -653,6 +656,12 @@ netbsd*)
EXTRASYSSRCS="paranoia.cpp NetBSD/sheepthreads.c ppc_asm.S" EXTRASYSSRCS="paranoia.cpp NetBSD/sheepthreads.c ppc_asm.S"
fi fi
;; ;;
solaris*)
dnl Needed for sys/socket.h
LDFLAGS="$LDFLAGS -lsocket -lnsl"
dnl Needed for SDL2
CXXFLAGS="$CXXFLAGS -std=c++11"
;;
darwin*) darwin*)
ETHERSRC=ether_unix.cpp ETHERSRC=ether_unix.cpp
if [[ "x$EMULATED_PPC" = "xno" ]]; then if [[ "x$EMULATED_PPC" = "xno" ]]; then
@ -978,18 +987,6 @@ AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
fi dnl HAVE_MMAP_VM fi dnl HAVE_MMAP_VM
dnl Check if we can disable position-independent code
AC_CACHE_CHECK([how to disable position-independent code],
ac_cv_no_pie, [
ac_cv_no_pie='-Wl,-no_pie'
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $ac_cv_no_pie"
AC_TRY_LINK(,,,[ac_cv_no_pie="cannot"])
if [[ "$ac_cv_no_pie" = "cannot" ]]; then
LDFLAGS="$saved_LDFLAGS"
fi
])
dnl Check if we can modify the __PAGEZERO segment for use as Low Memory dnl Check if we can modify the __PAGEZERO segment for use as Low Memory
AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x3000], AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x3000],
ac_cv_pagezero_hack, [ ac_cv_pagezero_hack, [

View File

@ -29,6 +29,10 @@
#include <net/if.h> #include <net/if.h>
#include <net/if_arp.h> #include <net/if_arp.h>
#ifdef __sun__
#include <sys/sockio.h>
#endif
#include <cerrno> #include <cerrno>
#include "user_strings.h" #include "user_strings.h"

View File

@ -1,271 +0,0 @@
/*
* prefs_unix.cpp - Preferences handling, Unix specific stuff
*
* SheepShaver (C) 1997-2008 Christian Bauer and Marc Hellwig
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "sysdeps.h"
#include <sys/stat.h>
#include <string>
using std::string;
#include "prefs.h"
// Platform-specific preferences items
prefs_desc platform_prefs_items[] = {
{"ether", TYPE_STRING, false, "device name of Mac ethernet adapter"},
{"etherconfig", TYPE_STRING, false, "path of network config script"},
{"keycodes", TYPE_BOOLEAN, false, "use keycodes rather than keysyms to decode keyboard"},
{"keycodefile", TYPE_STRING, false, "path of keycode translation file"},
{"mousewheelmode", TYPE_INT32, false, "mouse wheel support mode (0=page up/down, 1=cursor up/down)"},
{"mousewheellines", TYPE_INT32, false, "number of lines to scroll in mouse wheel mode 1"},
{"dsp", TYPE_STRING, false, "audio output (dsp) device name"},
{"mixer", TYPE_STRING, false, "audio mixer device name"},
{"idlewait", TYPE_BOOLEAN, false, "sleep when idle"},
#ifdef USE_SDL_VIDEO
{"sdlrender", TYPE_STRING, false, "SDL_Renderer driver (\"auto\", \"software\" (may be faster), etc.)"},
#endif
{NULL, TYPE_END, false, NULL} // End of list
};
// Standard file names and paths
static const char PREFS_FILE_NAME[] = "/.sheepshaver_prefs";
static const char XDG_PREFS_FILE_NAME[] = "/prefs";
static const char XPRAM_FILE_NAME[] = "/.sheepshaver_nvram";
static const char XDG_XPRAM_FILE_NAME[] = "/nvram";
static const char XDG_CONFIG_SUBDIR[] = "/SheepShaver";
// Prefs file name and path
string UserPrefsPath;
static string home_dir;
static string xdg_config_dir;
static string prefs_name;
extern string xpram_name;
static string get_xdg_config_dir(void)
{
char *env;
if (env = getenv("XDG_CONFIG_HOME"))
return string(env) + XDG_CONFIG_SUBDIR;
if (env = getenv("HOME"))
return string(env) + "/.config" + XDG_CONFIG_SUBDIR;
return "";
}
static string get_home_dir(void)
{
char *env;
if(env = getenv("HOME"))
return string(env);
return "."; // last resort, use the current directory
}
static string get_dir(string *path)
{
int pos = path->find_last_of('/');
if (pos == 0)
return ""; // file is in root folder
if (pos == std::string::npos)
return "."; // file is in current folder
return path->substr(0, pos);
}
static void exit_if_dir(const string& path)
{
struct stat info;
if (stat(path.c_str(), &info) != 0){
return;
}
if ((info.st_mode & S_IFDIR) != 0)
{
fprintf(stderr, "ERROR: Cannot open %s (Is a directory)\n", prefs_name.c_str());
exit(1);
}
}
static bool load_prefs_file(const string& path, bool exit_on_failure)
{
exit_if_dir(path);
FILE *prefs = fopen(path.c_str(), "r");
if (prefs != NULL)
{
LoadPrefsFromStream(prefs);
fclose(prefs);
printf("Using prefs file at %s\n", prefs_name.c_str());
return true;
}
else if (exit_on_failure)
{
fprintf(stderr, "ERROR: Could not load prefs file from %s (%s)\n",
path.c_str(), strerror(errno));
exit(1);
}
return false;
}
/*
* Look for prefs file in the following locations (in order of priority):
* 1. From vmdir/.sheepshaver_prefs if a vmdir has been specified
* 2. From path specified with --config command line
* 3. From $HOME/.sheepshaver_prefs if it exists
* 4. From $XDG_CONFIG_HOME/SheepShaver/prefs if it exists
* 5. Create a new prefs file at $XDG_CONFIG_HOME/SheepShaver/prefs
* If $XDG_CONFIG_HOME doesn't exist, $HOME/.config is used instead,
* in accordance with XDG Base Directory Specification:
* https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
*/
void LoadPrefs(const char* vmdir)
{
home_dir = get_home_dir();
xdg_config_dir = get_xdg_config_dir();
// vmdir was specified on the command line
if (vmdir)
{
prefs_name = string(vmdir) + XDG_PREFS_FILE_NAME;
xpram_name = string(vmdir) + XDG_XPRAM_FILE_NAME;
if (load_prefs_file(prefs_name, true))
return;
}
// --config was specified
if (!UserPrefsPath.empty())
{
prefs_name = UserPrefsPath;
xpram_name = get_dir(&prefs_name) + XPRAM_FILE_NAME;
if (load_prefs_file(prefs_name, true))
return;
}
// Load .basilisk_ii_prefs from $HOME if it exists
if (!home_dir.empty())
{
prefs_name = home_dir + PREFS_FILE_NAME;
xpram_name = home_dir + XPRAM_FILE_NAME;
if (load_prefs_file(prefs_name, false))
return;
}
// If no other prefs file exists, try the $XDG_CONFIG_HOME directory
if (!xdg_config_dir.empty())
{
prefs_name = xdg_config_dir + XDG_PREFS_FILE_NAME;
xpram_name = xdg_config_dir + XDG_XPRAM_FILE_NAME;
if (load_prefs_file(prefs_name, false))
return;
}
// No prefs file, save defaults in $XDG_CONFIG_HOME directory
#ifdef __linux__
PrefsAddString("cdrom", "/dev/cdrom");
#endif
printf("No prefs file found, creating new one at %s\n", prefs_name.c_str());
SavePrefs();
}
static bool is_dir(const string& path)
{
struct stat info;
if (stat(path.c_str(), &info) != 0){
return false;
}
return (info.st_mode & S_IFDIR) != 0;
}
static bool create_directories(const string& path, mode_t mode)
{
if (mkdir(path.c_str(), mode) == 0)
return true;
switch (errno)
{
case ENOENT:
{
int pos = path.find_last_of('/');
if (pos == std::string::npos)
return false;
if (!create_directories(path.substr(0,pos),mode))
return false;
}
return 0 == mkdir(path.c_str(),mode);
case EEXIST:
return is_dir(path);
default:
return false;
}
}
/*
* Save preferences to settings file
*/
void SavePrefs(void)
{
FILE *f;
string prefs_dir = get_dir(&prefs_name);
if (!prefs_dir.empty() && !is_dir(prefs_dir))
{
create_directories(prefs_dir, 0700);
}
if ((f = fopen(prefs_name.c_str(), "w")) != NULL)
{
SavePrefsToStream(f);
fclose(f);
}
else
{
fprintf(stderr, "WARNING: Unable to save %s (%s)\n",
prefs_name.c_str(), strerror(errno));
}
}
/*
* Add defaults of platform-specific prefs items
* You may also override the defaults set in PrefsInit()
*/
void AddPlatformPrefsDefaults(void)
{
PrefsAddBool("keycodes", false);
PrefsReplaceString("extfs", "/");
PrefsReplaceInt32("mousewheelmode", 1);
PrefsReplaceInt32("mousewheellines", 3);
#ifdef __linux__
if (access("/dev/sound/dsp", F_OK) == 0)
{
PrefsReplaceString("dsp", "/dev/sound/dsp");
}
else
{
PrefsReplaceString("dsp", "/dev/dsp");
}
if (access("/dev/sound/mixer", F_OK) == 0)
{
PrefsReplaceString("mixer", "/dev/sound/mixer");
}
else
{
PrefsReplaceString("mixer", "/dev/mixer");
}
#else
PrefsReplaceString("dsp", "/dev/dsp");
PrefsReplaceString("mixer", "/dev/mixer");
#endif
PrefsAddBool("idlewait", true);
}

View File

@ -0,0 +1 @@
../../../BasiliskII/src/Unix/prefs_unix.cpp

View File

@ -44,6 +44,7 @@
#include <stddef.h> #include <stddef.h>
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <errno.h>
#ifdef HAVE_PTHREADS #ifdef HAVE_PTHREADS
# include <pthread.h> # include <pthread.h>
@ -53,6 +54,10 @@
# include <fcntl.h> # include <fcntl.h>
#endif #endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef TIME_WITH_SYS_TIME #ifdef TIME_WITH_SYS_TIME
# include <sys/time.h> # include <sys/time.h>
# include <time.h> # include <time.h>
@ -170,6 +175,9 @@ typedef int64 intptr;
#else #else
#error "Unsupported size of pointer" #error "Unsupported size of pointer"
#endif #endif
#ifndef HAVE_LOFF_T
#define loff_t off_t
#endif
// Define if the host processor supports fast unaligned load/stores // Define if the host processor supports fast unaligned load/stores
#if defined __i386__ || defined __x86_64__ #if defined __i386__ || defined __x86_64__