diff --git a/BasiliskII/src/Unix/Makefile.in b/BasiliskII/src/Unix/Makefile.in index 63580e35..a3a864a7 100644 --- a/BasiliskII/src/Unix/Makefile.in +++ b/BasiliskII/src/Unix/Makefile.in @@ -29,7 +29,7 @@ INSTALL_DATA = @INSTALL_DATA@ SRCS = ../main.cpp main_unix.cpp ../prefs.cpp prefs_unix.cpp sys_unix.cpp \ ../rom_patches.cpp ../slot_rom.cpp ../rsrc_patches.cpp ../emul_op.cpp \ ../macos_util.cpp ../xpram.cpp xpram_unix.cpp ../timer.cpp timer_unix.cpp \ - clip_unix.cpp ../adb.cpp ../serial.cpp serial_unix.cpp ../ether.cpp ../sony.cpp \ + clip_unix.cpp ../adb.cpp ../serial.cpp ../ether.cpp ../sony.cpp \ ../disk.cpp ../cdrom.cpp ../scsi.cpp ../video.cpp video_x.cpp ../audio.cpp \ ../extfs.cpp extfs_unix.cpp ../user_strings.cpp user_strings_unix.cpp \ $(SYSSRCS) $(CPUSRCS) diff --git a/BasiliskII/src/Unix/acconfig.h b/BasiliskII/src/Unix/acconfig.h index d3abf0a6..64a2fc18 100644 --- a/BasiliskII/src/Unix/acconfig.h +++ b/BasiliskII/src/Unix/acconfig.h @@ -1,4 +1,48 @@ -/* Additional defines for autoheader. */ +/* acconfig.h + This file is in the public domain. + + Descriptive text for the C preprocessor macros that + the distributed Autoconf macros can define. + No software package will use all of them; autoheader copies the ones + your configure.in uses into your configuration header file templates. + + The entries are in sort -df order: alphabetical, case insensitive, + ignoring punctuation (such as underscores). Although this order + can split up related entries, it makes it easier to check whether + a given entry is in the file. + + Leave the following blank line there!! Autoheader needs it. */ + /* Define to 'off_t' if doesn't define. */ #undef loff_t + +/* Define if using ESD. */ +#undef ENABLE_ESD + +/* Define if using DGA with framebuffer device. */ +#undef ENABLE_FBDEV_DGA + +/* Define if using GTK. */ +#undef ENABLE_GTK + +/* Define if using "mon". */ +#undef ENABLE_MON + +/* Define if using native 68k mode. */ +#undef ENABLE_NATIVE_M68K + +/* Define if using XFree86 DGA extension. */ +#undef ENABLE_XF86_DGA + +/* Define if using XFree86 VidMode extension. */ +#undef ENABLE_XF86_VIDMODE + +/* Define if pthreads are available. */ +#undef HAVE_PTHREADS + + +/* Leave that blank line there!! Autoheader needs it. + If you're adding to this file, keep in mind: + The entries are in sort -df order: alphabetical, case insensitive, + ignoring punctuation (such as underscores). */ diff --git a/BasiliskII/src/Unix/asm_support.s b/BasiliskII/src/Unix/asm_support.s new file mode 100644 index 00000000..a1957654 --- /dev/null +++ b/BasiliskII/src/Unix/asm_support.s @@ -0,0 +1,246 @@ +/* + * asm_support.s - Utility functions in assemmbly language + * + * Basilisk II (C) 1997-1999 Christian Bauer + * + * 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 + */ + + .file "asm_support.s" + .text + + .globl _m68k_sync_icache + .globl _Start680x0__Fv + .globl _SetInterruptFlag__FUi + .globl _ClearInterruptFlag__FUi + .globl _Execute68k + .globl _Execute68kTrap + .globl _Scod060Patch1 + .globl _Scod060Patch2 + .globl _ThInitFPUPatch + .globl _EmulOpTrampoline + + .globl _RAMBaseHost + .globl _ROMBaseHost + .globl _EmulOp__FUsP13M68kRegisters + .globl _EmulatedSR + .globl _InterruptFlags + .globl _TriggerInterrupt__Fv + + +/* + * Call m68k_sync_icache() (NetBSD, the version in libm68k is broken) + */ + + .type _m68k_sync_icache,@function +_m68k_sync_icache: + movl sp@(8),d1 + movl sp@(4),a1 + movl #0x80000004,d0 + trap #12 + rts + + +/* + * Jump to Mac ROM, start emulation + */ + + .type _Start680x0__Fv,@function +_Start680x0__Fv: + movl _RAMBaseHost,a0 + addl #0x8000,a0 + movl a0,sp + movl _ROMBaseHost,a0 + lea a0@(0x2a),a0 + jmp a0@ + + +/* + * Set/clear interrupt flag (atomically) + */ + + .type _SetInterruptFlag__FUi,@function +_SetInterruptFlag__FUi: + movl sp@(4),d0 + orl d0,_InterruptFlags + rts + + .type _ClearInterruptFlag__FUi,@function +_ClearInterruptFlag__FUi: + movl sp@(4),d0 + notl d0 + andl d0,_InterruptFlags + rts + + +/* + * Execute 68k subroutine (must be ended with rts) + * r->a[7] and r->sr are unused! + */ + +/* void Execute68k(uint32 addr, M68kRegisters *r); */ + .type _Execute68k,@function +_Execute68k: movl sp@(4),d0 |Get arguments + movl sp@(8),a0 + + movml d2-d7/a2-a6,sp@- |Save registers + + movl a0,sp@- |Push pointer to M68kRegisters on stack + pea exec68kret |Push return address on stack + movl d0,sp@- |Push pointer to 68k routine on stack + movml a0@,d0-d7/a0-a6 |Load registers from M68kRegisters + + rts |Jump into 68k routine + +exec68kret: movl a6,sp@- |Save a6 + movl sp@(4),a6 |Get pointer to M68kRegisters + movml d0-d7/a0-a5,a6@ |Save d0-d7/a0-a5 to M68kRegisters + movl sp@+,a6@(56) |Save a6 to M68kRegisters + addql #4,sp |Remove pointer from stack + + movml sp@+,d2-d7/a2-a6 |Restore registers + rts + + +/* + * Execute MacOS 68k trap + * r->a[7] and r->sr are unused! + */ + +/* void Execute68kTrap(uint16 trap, M68kRegisters *r); */ + .type _Execute68kTrap,@function +_Execute68kTrap: + movl sp@(4),d0 |Get arguments + movl sp@(8),a0 + + movml d2-d7/a2-a6,sp@- |Save registers + + movl a0,sp@- |Push pointer to M68kRegisters on stack + movw d0,sp@- |Push trap word on stack + subql #8,sp |Create fake A-Line exception frame + movml a0@,d0-d7/a0-a6 |Load registers from M68kRegisters + + movl a2,sp@- |Save a2 and d2 + movl d2,sp@- + lea exectrapret,a2 |a2 points to return address + movw sp@(16),d2 |Load trap word into d2 + + jmp zpc@(0x28:w)@(10) |Jump into MacOS A-Line handler + +exectrapret: movl a6,sp@- |Save a6 + movl sp@(6),a6 |Get pointer to M68kRegisters + movml d0-d7/a0-a5,a6@ |Save d0-d7/a0-a5 to M68kRegisters + movl sp@+,a6@(56) |Save a6 to M68kRegisters + addql #6,sp |Remove pointer and trap word from stack + + movml sp@+,d2-d7/a2-a6 |Restore registers + rts + + +/* + * Call EmulOp() after return from SIGILL handler, registers are pushed on stack + */ + + .type _EmulOpTrampoline,@function +_EmulOpTrampoline: + movl sp,a0 |Get pointer to registers + + movw _EmulatedSR,d0 |Save EmulatedSR, disable interrupts + movw d0,sp@- + oriw #0x0700,d0 + movw d0,_EmulatedSR + + movl a0,sp@- |Push pointer to registers + movl a0@(66),a1 |Get saved PC + addql #2,a0@(66) |Skip EMUL_OP opcode + movw a1@,sp@- |Push opcode word + clrw sp@- + jbsr _EmulOp__FUsP13M68kRegisters + addql #8,sp + + movw sp@+,d0 |Restore interrupts, trigger pending interrupt + movw d0,_EmulatedSR + andiw #0x0700,d0 + bne eot1 + tstl _InterruptFlags + beq eot1 + jbsr _TriggerInterrupt__Fv + +eot1: moveml sp@+,d0-d7/a0-a6 |Restore registers + addql #4,sp |Skip saved SP + rtr + + +/* + * Process Manager 68060 FPU patches + */ + + .type _Scod060Patch1,@function +_Scod060Patch1: fsave sp@- |Save FPU state + tstb sp@(2) |Null? + beqs sc1 + fmovemx fp0-fp7,sp@- |No, save FPU registers + fmovel fpi,sp@- + fmovel fpsr,sp@- + fmovel fpcr,sp@- + pea -1 |Push "FPU state saved" flag +sc1: movl d1,sp@- + movl d0,sp@- + bsrs sc3 |Switch integer registers and stack + addql #8,sp + tstb sp@(2) |New FPU state null or "FPU state saved" flag set? + beqs sc2 + addql #4,sp |Flag set, skip it + fmovel sp@+,fpcr |Restore FPU registers and state + fmovel sp@+,fpsr + fmovel sp@+,fpi + fmovemx sp@+,fp0-fp7 +sc2: frestore sp@+ + movml sp@+,d0-d1 + rts + +sc3: movl sp@(4),a0 |Switch integer registers and stack + movw sr,sp@- + movml d2-d7/a2-a6,sp@- + cmpw #0,a0 + beqs sc4 + movl sp,a0@ +sc4: movl sp@(0x36),a0 + movml a0@+,d2-d7/a2-a6 + movw a0@+,sr + movl a0,sp + rts + + .type _Scod060Patch2,@function +_Scod060Patch2: movl d0,sp@- |Create 68060 null frame on stack + movl d0,sp@- + movl d0,sp@- + frestore sp@+ |and load it + rts + + +/* + * Thread Manager 68060 FPU patches + */ + + .type _ThInitFPUPatch,@function +_ThInitFPUPatch: + tstb a4@(0x40) + bnes th1 + moveq #0,d0 |Create 68060 null frame on stack + movl d0,a3@- + movl d0,a3@- + movl d0,a3@- +th1: rts diff --git a/BasiliskII/src/Unix/audio_oss_esd.cpp b/BasiliskII/src/Unix/audio_oss_esd.cpp index 703ba1b8..b9986f3e 100644 --- a/BasiliskII/src/Unix/audio_oss_esd.cpp +++ b/BasiliskII/src/Unix/audio_oss_esd.cpp @@ -41,7 +41,7 @@ #include "audio.h" #include "audio_defs.h" -#if ENABLE_ESD +#ifdef ENABLE_ESD #include #endif @@ -138,7 +138,7 @@ bool audio_init_dsp(void) // Init using ESD, returns false on error bool audio_init_esd(void) { -#if ENABLE_ESD +#ifdef ENABLE_ESD printf("Using ESD audio output\n"); // ESD audio format @@ -195,7 +195,7 @@ void AudioInit(void) // Try to open /dev/dsp audio_fd = open(DSP_NAME, O_WRONLY); if (audio_fd < 0) { -#if ENABLE_ESD +#ifdef ENABLE_ESD if (!audio_init_esd()) return; #else diff --git a/BasiliskII/src/Unix/config.h.in b/BasiliskII/src/Unix/config.h.in index 31cc74fd..350f1ca4 100644 --- a/BasiliskII/src/Unix/config.h.in +++ b/BasiliskII/src/Unix/config.h.in @@ -31,6 +31,30 @@ /* Define to 'off_t' if doesn't define. */ #undef loff_t +/* Define if using ESD. */ +#undef ENABLE_ESD + +/* Define if using DGA with framebuffer device. */ +#undef ENABLE_FBDEV_DGA + +/* Define if using GTK. */ +#undef ENABLE_GTK + +/* Define if using "mon". */ +#undef ENABLE_MON + +/* Define if using native 68k mode. */ +#undef ENABLE_NATIVE_M68K + +/* Define if using XFree86 DGA extension. */ +#undef ENABLE_XF86_DGA + +/* Define if using XFree86 VidMode extension. */ +#undef ENABLE_XF86_VIDMODE + +/* Define if pthreads are available. */ +#undef HAVE_PTHREADS + /* The number of bytes in a int. */ #undef SIZEOF_INT @@ -67,6 +91,12 @@ /* Define if you have the header file. */ #undef HAVE_FCNTL_H +/* Define if you have the header file. */ +#undef HAVE_HISTORY_H + +/* Define if you have the header file. */ +#undef HAVE_READLINE_H + /* Define if you have the header file. */ #undef HAVE_READLINE_HISTORY_H @@ -87,3 +117,6 @@ /* Define if you have the readline library (-lreadline). */ #undef HAVE_LIBREADLINE + +/* Define if you have the termcap library (-ltermcap). */ +#undef HAVE_LIBTERMCAP diff --git a/BasiliskII/src/Unix/configure b/BasiliskII/src/Unix/configure index 8b2cd204..5ed6d649 100755 --- a/BasiliskII/src/Unix/configure +++ b/BasiliskII/src/Unix/configure @@ -1155,17 +1155,89 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' +HAVE_I386=no +echo $ac_n "checking for x86 target CPU""... $ac_c" 1>&6 +echo "configure:1161: checking for x86 target CPU" >&5 +cat > conftest.$ac_ext <&5 | + egrep "yes" >/dev/null 2>&1; then + rm -rf conftest* + echo "$ac_t""yes" 1>&6; HAVE_I386=yes +else + rm -rf conftest* + echo "$ac_t""no" 1>&6 +fi +rm -f conftest* + + +HAVE_SPARC=no +echo $ac_n "checking for SPARC target CPU""... $ac_c" 1>&6 +echo "configure:1184: checking for SPARC target CPU" >&5 +cat > conftest.$ac_ext <&5 | + egrep "yes" >/dev/null 2>&1; then + rm -rf conftest* + echo "$ac_t""yes" 1>&6; HAVE_SPARC=yes +else + rm -rf conftest* + echo "$ac_t""no" 1>&6 +fi +rm -f conftest* + + +HAVE_M68K=no +echo $ac_n "checking for m68k target CPU""... $ac_c" 1>&6 +echo "configure:1207: checking for m68k target CPU" >&5 +cat > conftest.$ac_ext <&5 | + egrep "yes" >/dev/null 2>&1; then + rm -rf conftest* + echo "$ac_t""yes" 1>&6; HAVE_M68K=yes +else + rm -rf conftest* + echo "$ac_t""no" 1>&6 +fi +rm -f conftest* + + MONSRCS= if [ "x$WANT_MON" = "xyes" ]; then echo $ac_n "checking for mon""... $ac_c" 1>&6 -echo "configure:1162: checking for mon" >&5 +echo "configure:1231: checking for mon" >&5 if grep mon_init ../../../mon/src/mon.h >/dev/null 2>/dev/null; then echo "$ac_t""yes" 1>&6 - DEFINES="$DEFINES -DENABLE_MON=1" + cat >> confdefs.h <<\EOF +#define ENABLE_MON 1 +EOF + MONSRCS="../../../mon/src/mon.cpp ../../../mon/src/mon_6502.cpp ../../../mon/src/mon_68k.cpp ../../../mon/src/mon_8080.cpp ../../../mon/src/mon_cmd.cpp ../../../mon/src/mon_ppc.cpp ../../../mon/src/mon_x86.cpp" CXXFLAGS="$CXXFLAGS -I../../../mon/src" echo $ac_n "checking for readline in -lreadline""... $ac_c" 1>&6 -echo "configure:1169: checking for readline in -lreadline" >&5 +echo "configure:1241: checking for readline in -lreadline" >&5 ac_lib_var=`echo readline'_'readline | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1173,7 +1245,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lreadline $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1260: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1211,21 +1283,68 @@ else echo "$ac_t""no" 1>&6 fi - for ac_hdr in readline/readline.h readline/history.h + echo $ac_n "checking for tputs in -ltermcap""... $ac_c" 1>&6 +echo "configure:1288: checking for tputs in -ltermcap" >&5 +ac_lib_var=`echo termcap'_'tputs | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ltermcap $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo termcap | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +fi + + for ac_hdr in readline.h history.h readline/readline.h readline/history.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1219: checking for $ac_hdr" >&5 +echo "configure:1338: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1229: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1348: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1255,12 +1374,11 @@ done echo "$ac_t""no" 1>&6 echo "configure: warning: Could not find mon, ignoring --with-mon." 1>&2 WANT_MON=no - DEFINES="$DEFINES -DENABLE_MON=0" fi fi echo $ac_n "checking for sem_init in -lposix4""... $ac_c" 1>&6 -echo "configure:1264: checking for sem_init in -lposix4" >&5 +echo "configure:1382: checking for sem_init in -lposix4" >&5 ac_lib_var=`echo posix4'_'sem_init | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1268,7 +1386,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lposix4 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1401: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1312,7 +1430,7 @@ fi # Uses ac_ vars as temps to allow command line to override cache and checks. # --without-x overrides everything else, but does not touch the cache. echo $ac_n "checking for X""... $ac_c" 1>&6 -echo "configure:1316: checking for X" >&5 +echo "configure:1434: checking for X" >&5 # Check whether --with-x or --without-x was given. if test "${with_x+set}" = set; then @@ -1374,12 +1492,12 @@ if test "$ac_x_includes" = NO; then # First, try using that file with no special directory specified. cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1383: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1501: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1448,14 +1566,14 @@ if test "$ac_x_libraries" = NO; then ac_save_LIBS="$LIBS" LIBS="-l$x_direct_test_library $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1577: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* LIBS="$ac_save_LIBS" # We can link X programs with no special library path. @@ -1561,17 +1679,17 @@ else case "`(uname -sr) 2>/dev/null`" in "SunOS 5"*) echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6 -echo "configure:1565: checking whether -R must be followed by a space" >&5 +echo "configure:1683: checking whether -R must be followed by a space" >&5 ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1693: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_R_nospace=yes else @@ -1587,14 +1705,14 @@ rm -f conftest* else LIBS="$ac_xsave_LIBS -R $x_libraries" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1716: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_R_space=yes else @@ -1626,7 +1744,7 @@ rm -f conftest* # libraries were built with DECnet support. And karl@cs.umb.edu says # the Alpha needs dnet_stub (dnet does not exist). echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6 -echo "configure:1630: checking for dnet_ntoa in -ldnet" >&5 +echo "configure:1748: checking for dnet_ntoa in -ldnet" >&5 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1634,7 +1752,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldnet $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1767: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1667,7 +1785,7 @@ fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6 -echo "configure:1671: checking for dnet_ntoa in -ldnet_stub" >&5 +echo "configure:1789: checking for dnet_ntoa in -ldnet_stub" >&5 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1675,7 +1793,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldnet_stub $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1808: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1715,12 +1833,12 @@ fi # The nsl library prevents programs from opening the X display # on Irix 5.2, according to dickey@clark.net. echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 -echo "configure:1719: checking for gethostbyname" >&5 +echo "configure:1837: checking for gethostbyname" >&5 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1865: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gethostbyname=yes" else @@ -1764,7 +1882,7 @@ fi if test $ac_cv_func_gethostbyname = no; then echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 -echo "configure:1768: checking for gethostbyname in -lnsl" >&5 +echo "configure:1886: checking for gethostbyname in -lnsl" >&5 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1772,7 +1890,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1905: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1813,12 +1931,12 @@ fi # -lsocket must be given before -lnsl if both are needed. # We assume that if connect needs -lnsl, so does gethostbyname. echo $ac_n "checking for connect""... $ac_c" 1>&6 -echo "configure:1817: checking for connect" >&5 +echo "configure:1935: checking for connect" >&5 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1963: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_connect=yes" else @@ -1862,7 +1980,7 @@ fi if test $ac_cv_func_connect = no; then echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6 -echo "configure:1866: checking for connect in -lsocket" >&5 +echo "configure:1984: checking for connect in -lsocket" >&5 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1870,7 +1988,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2003: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1905,12 +2023,12 @@ fi # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX. echo $ac_n "checking for remove""... $ac_c" 1>&6 -echo "configure:1909: checking for remove" >&5 +echo "configure:2027: checking for remove" >&5 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2055: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_remove=yes" else @@ -1954,7 +2072,7 @@ fi if test $ac_cv_func_remove = no; then echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6 -echo "configure:1958: checking for remove in -lposix" >&5 +echo "configure:2076: checking for remove in -lposix" >&5 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1962,7 +2080,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lposix $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2095: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1997,12 +2115,12 @@ fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. echo $ac_n "checking for shmat""... $ac_c" 1>&6 -echo "configure:2001: checking for shmat" >&5 +echo "configure:2119: checking for shmat" >&5 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_shmat=yes" else @@ -2046,7 +2164,7 @@ fi if test $ac_cv_func_shmat = no; then echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6 -echo "configure:2050: checking for shmat in -lipc" >&5 +echo "configure:2168: checking for shmat in -lipc" >&5 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2054,7 +2172,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lipc $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2187: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2098,7 +2216,7 @@ fi # libraries we check for below, so use a different variable. # --interran@uluru.Stanford.EDU, kb@cs.umb.edu. echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6 -echo "configure:2102: checking for IceConnectionNumber in -lICE" >&5 +echo "configure:2220: checking for IceConnectionNumber in -lICE" >&5 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2106,7 +2224,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lICE $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2239: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2148,8 +2266,9 @@ CFLAGS="$CFLAGS $X_CFLAGS" CXXFLAGS="$CXXFLAGS $X_CFLAGS" LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS" +HAVE_PTHREADS=yes echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:2153: checking for pthread_create in -lpthread" >&5 +echo "configure:2272: checking for pthread_create in -lpthread" >&5 ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2157,7 +2276,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2291: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2195,7 +2314,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6 -echo "configure:2199: checking for pthread_create in -lc_r" >&5 +echo "configure:2318: checking for pthread_create in -lc_r" >&5 ac_lib_var=`echo c_r'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2203,7 +2322,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lc_r $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2337: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2241,7 +2360,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lPTL""... $ac_c" 1>&6 -echo "configure:2245: checking for pthread_create in -lPTL" >&5 +echo "configure:2364: checking for pthread_create in -lPTL" >&5 ac_lib_var=`echo PTL'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2249,7 +2368,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lPTL $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2383: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2286,7 +2405,7 @@ EOF else echo "$ac_t""no" 1>&6 - { echo "configure: error: You need pthreads to run Basilisk II." 1>&2; exit 1; } + HAVE_PTHREADS=no fi @@ -2296,17 +2415,21 @@ fi fi +if [ "x$HAVE_PTHREADS" = "xyes" ]; then + cat >> confdefs.h <<\EOF +#define HAVE_PTHREADS 1 +EOF -SEMSRCS= -for ac_func in sem_init +fi +for ac_func in pthread_cancel do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2305: checking for $ac_func" >&5 +echo "configure:2428: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2456: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2350,7 +2473,66 @@ EOF else echo "$ac_t""no" 1>&6 -SEMSRCS=posix_sem.cpp +fi +done + + +SEMSRC= +for ac_func in sem_init +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:2485: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2513: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +if "x$HAVE_PTHREADS" = "xyes" ; then + SEMSRC=posix_sem.cpp + fi fi done @@ -2358,7 +2540,7 @@ done if [ "x$WANT_XF86_DGA" = "xyes" ]; then echo $ac_n "checking for XF86DGAQueryExtension in -lXxf86dga""... $ac_c" 1>&6 -echo "configure:2362: checking for XF86DGAQueryExtension in -lXxf86dga" >&5 +echo "configure:2544: checking for XF86DGAQueryExtension in -lXxf86dga" >&5 ac_lib_var=`echo Xxf86dga'_'XF86DGAQueryExtension | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2366,7 +2548,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lXxf86dga $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2563: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2393,7 +2575,10 @@ fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 - DEFINES="$DEFINES -DENABLE_XF86_DGA=1" + cat >> confdefs.h <<\EOF +#define ENABLE_XF86_DGA 1 +EOF + LIBS="$LIBS -lXxf86dga" if [ "x$WANT_FBDEV_DGA" = "xyes" ]; then echo "configure: warning: Cannot have both --enable-xf86-dga and --enable-fbdev-dga, ignoring --enable-fbdev-dga." 1>&2 @@ -2405,22 +2590,20 @@ else echo "configure: warning: Could not find XFree86 DGA extension, ignoring --enable-xf86-dga." 1>&2 WANT_XF86_DGA=no - DEFINES="$DEFINES -DENABLE_XF86_DGA=0" fi -else - DEFINES="$DEFINES -DENABLE_XF86_DGA=0" fi if [ "x$WANT_FBDEV_DGA" = "xyes" ]; then - DEFINES="$DEFINES -DENABLE_FBDEV_DGA=1" -else - DEFINES="$DEFINES -DENABLE_FBDEV_DGA=0" + cat >> confdefs.h <<\EOF +#define ENABLE_FBDEV_DGA 1 +EOF + fi if [ "x$WANT_XF86_VIDMODE" = "xyes" ]; then echo $ac_n "checking for XF86VidModeQueryExtension in -lXxf86vm""... $ac_c" 1>&6 -echo "configure:2424: checking for XF86VidModeQueryExtension in -lXxf86vm" >&5 +echo "configure:2607: checking for XF86VidModeQueryExtension in -lXxf86vm" >&5 ac_lib_var=`echo Xxf86vm'_'XF86VidModeQueryExtension | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2428,7 +2611,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lXxf86vm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2626: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2455,7 +2638,10 @@ fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 - DEFINES="$DEFINES -DENABLE_XF86_VIDMODE=1" + cat >> confdefs.h <<\EOF +#define ENABLE_XF86_VIDMODE 1 +EOF + LIBS="$LIBS -lXxf86vm" else @@ -2463,7 +2649,6 @@ else echo "configure: warning: Could not find XFree86 VidMode extension, ignoring --enable-xf86-vidmode." 1>&2 WANT_XF86_VIDMODE=no - DEFINES="$DEFINES -DENABLE_XF86_VIDMODE=0" fi @@ -2512,7 +2697,7 @@ fi # Extract the first word of "gtk-config", so it can be a program name with args. set dummy gtk-config; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2516: checking for $ac_word" >&5 +echo "configure:2701: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GTK_CONFIG'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2547,7 +2732,7 @@ fi min_gtk_version=1.2.0 echo $ac_n "checking for GTK - version >= $min_gtk_version""... $ac_c" 1>&6 -echo "configure:2551: checking for GTK - version >= $min_gtk_version" >&5 +echo "configure:2736: checking for GTK - version >= $min_gtk_version" >&5 no_gtk="" if test "$GTK_CONFIG" = "no" ; then no_gtk=yes @@ -2570,7 +2755,7 @@ echo "configure:2551: checking for GTK - version >= $min_gtk_version" >&5 echo $ac_n "cross compiling; assumed OK... $ac_c" else cat > conftest.$ac_ext < @@ -2633,7 +2818,7 @@ main () } EOF -if { (eval echo configure:2637: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2822: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -2652,7 +2837,10 @@ fi if test "x$no_gtk" = x ; then echo "$ac_t""yes" 1>&6 - DEFINES="$DEFINES -DENABLE_GTK=1" + cat >> confdefs.h <<\EOF +#define ENABLE_GTK 1 +EOF + CFLAGS="$CFLAGS $GTK_CFLAGS" CXXFLAGS="$CXXFLAGS $GTK_CFLAGS" LIBS="$LIBS $GTK_LIBS" @@ -2673,7 +2861,7 @@ fi CFLAGS="$CFLAGS $GTK_CFLAGS" LIBS="$LIBS $GTK_LIBS" cat > conftest.$ac_ext < @@ -2683,7 +2871,7 @@ int main() { return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ; return 0; } EOF -if { (eval echo configure:2687: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding GTK or finding the wrong" @@ -2718,7 +2906,6 @@ rm -f conftest* echo "configure: warning: Could not find GTK+, disabling user interface." 1>&2 WANT_GTK=no - DEFINES="$DEFINES -DENABLE_GTK=0" fi @@ -2769,7 +2956,7 @@ fi # Extract the first word of "esd-config", so it can be a program name with args. set dummy esd-config; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2773: checking for $ac_word" >&5 +echo "configure:2960: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_ESD_CONFIG'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2804,7 +2991,7 @@ fi min_esd_version=0.2.8 echo $ac_n "checking for ESD - version >= $min_esd_version""... $ac_c" 1>&6 -echo "configure:2808: checking for ESD - version >= $min_esd_version" >&5 +echo "configure:2995: checking for ESD - version >= $min_esd_version" >&5 no_esd="" if test "$ESD_CONFIG" = "no" ; then no_esd=yes @@ -2828,7 +3015,7 @@ echo "configure:2808: checking for ESD - version >= $min_esd_version" >&5 echo $ac_n "cross compiling; assumed OK... $ac_c" else cat > conftest.$ac_ext < @@ -2886,7 +3073,7 @@ int main () EOF -if { (eval echo configure:2890: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3077: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -2905,7 +3092,10 @@ fi if test "x$no_esd" = x ; then echo "$ac_t""yes" 1>&6 - DEFINES="$DEFINES -DENABLE_ESD=1" + cat >> confdefs.h <<\EOF +#define ENABLE_ESD 1 +EOF + CFLAGS="$CFLAGS $ESD_CFLAGS" CXXFLAGS="$CXXFLAGS $ESD_CFLAGS" LIBS="$LIBS $ESD_LIBS" @@ -2925,7 +3115,7 @@ fi CFLAGS="$CFLAGS $ESD_CFLAGS" LIBS="$LIBS $ESD_LIBS" cat > conftest.$ac_ext < @@ -2935,7 +3125,7 @@ int main() { return 0; ; return 0; } EOF -if { (eval echo configure:2939: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding ESD or finding the wrong" @@ -2965,7 +3155,6 @@ rm -f conftest* echo "configure: warning: Could not find ESD, disabling ESD support." 1>&2 WANT_ESD=no - DEFINES="$DEFINES -DENABLE_ESD=0" fi @@ -2975,12 +3164,12 @@ rm -f conftest* fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:2979: checking for ANSI C header files" >&5 +echo "configure:3168: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2988,7 +3177,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2992: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3181: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3005,7 +3194,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -3023,7 +3212,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -3044,7 +3233,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -3055,7 +3244,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:3059: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3248: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -3082,17 +3271,17 @@ for ac_hdr in unistd.h fcntl.h sys/time.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3086: checking for $ac_hdr" >&5 +echo "configure:3275: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3096: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3285: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3120,14 +3309,14 @@ done echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6 -echo "configure:3124: checking whether byte ordering is bigendian" >&5 +echo "configure:3313: checking whether byte ordering is bigendian" >&5 if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_bigendian=unknown # See if sys/param.h defines the BYTE_ORDER macro. cat > conftest.$ac_ext < #include @@ -3138,11 +3327,11 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:3142: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3331: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* # It does; now see whether it defined to BIG_ENDIAN or not. cat > conftest.$ac_ext < #include @@ -3153,7 +3342,7 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:3157: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3346: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_bigendian=yes else @@ -3173,7 +3362,7 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3379: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_bigendian=no else @@ -3210,12 +3399,12 @@ EOF fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:3214: checking for working const" >&5 +echo "configure:3403: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3457: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -3285,21 +3474,21 @@ EOF fi echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:3289: checking for inline" >&5 +echo "configure:3478: checking for inline" >&5 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3492: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -3325,7 +3514,7 @@ EOF esac echo $ac_n "checking size of short""... $ac_c" 1>&6 -echo "configure:3329: checking size of short" >&5 +echo "configure:3518: checking size of short" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3333,7 +3522,7 @@ else ac_cv_sizeof_short=2 else cat > conftest.$ac_ext < main() @@ -3344,7 +3533,7 @@ main() exit(0); } EOF -if { (eval echo configure:3348: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3537: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_short=`cat conftestval` else @@ -3364,7 +3553,7 @@ EOF echo $ac_n "checking size of int""... $ac_c" 1>&6 -echo "configure:3368: checking size of int" >&5 +echo "configure:3557: checking size of int" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3372,7 +3561,7 @@ else ac_cv_sizeof_int=4 else cat > conftest.$ac_ext < main() @@ -3383,7 +3572,7 @@ main() exit(0); } EOF -if { (eval echo configure:3387: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3576: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_int=`cat conftestval` else @@ -3403,7 +3592,7 @@ EOF echo $ac_n "checking size of long""... $ac_c" 1>&6 -echo "configure:3407: checking size of long" >&5 +echo "configure:3596: checking size of long" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3411,7 +3600,7 @@ else ac_cv_sizeof_long=4 else cat > conftest.$ac_ext < main() @@ -3422,7 +3611,7 @@ main() exit(0); } EOF -if { (eval echo configure:3426: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3615: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_long=`cat conftestval` else @@ -3442,7 +3631,7 @@ EOF echo $ac_n "checking size of long long""... $ac_c" 1>&6 -echo "configure:3446: checking size of long long" >&5 +echo "configure:3635: checking size of long long" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3450,7 +3639,7 @@ else ac_cv_sizeof_long_long=8 else cat > conftest.$ac_ext < main() @@ -3461,7 +3650,7 @@ main() exit(0); } EOF -if { (eval echo configure:3465: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3654: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_long_long=`cat conftestval` else @@ -3481,12 +3670,12 @@ EOF echo $ac_n "checking for off_t""... $ac_c" 1>&6 -echo "configure:3485: checking for off_t" >&5 +echo "configure:3674: checking for off_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -3514,12 +3703,12 @@ EOF fi echo $ac_n "checking for loff_t""... $ac_c" 1>&6 -echo "configure:3518: checking for loff_t" >&5 +echo "configure:3707: checking for loff_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_loff_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -3547,12 +3736,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:3551: checking for size_t" >&5 +echo "configure:3740: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -3580,12 +3769,12 @@ EOF fi echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:3584: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:3773: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -3594,7 +3783,7 @@ int main() { struct tm *tp; ; return 0; } EOF -if { (eval echo configure:3598: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3787: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -3615,12 +3804,12 @@ EOF fi echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 -echo "configure:3619: checking whether struct tm is in sys/time.h or time.h" >&5 +echo "configure:3808: checking whether struct tm is in sys/time.h or time.h" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -3628,7 +3817,7 @@ int main() { struct tm *tp; tp->tm_sec; ; return 0; } EOF -if { (eval echo configure:3632: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3821: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm=time.h else @@ -3652,12 +3841,12 @@ fi for ac_func in strdup cfmakeraw do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3656: checking for $ac_func" >&5 +echo "configure:3845: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3873: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3707,12 +3896,12 @@ done for ac_func in nanosleep clock_gettime timer_create do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3711: checking for $ac_func" >&5 +echo "configure:3900: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <&6 -fi -done - -for ac_func in pthread_cancel -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3766: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -$ac_func(); -#endif - -; return 0; } -EOF -if { (eval echo configure:3794: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3928: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3815,15 +3949,24 @@ fi done -SYSSRCS="../dummy/ether_dummy.cpp ../dummy/scsi_dummy.cpp ../dummy/audio_dummy.cpp" -if MACHINE=`uname -a 2>/dev/null`; then +SERIALSRC=serial_unix.cpp +ETHERSRC=../dummy/ether_dummy.cpp +SCSISRC=../dummy/scsi_dummy.cpp +AUDIOSRC=../dummy/audio_dummy.cpp +EXTRASYSSRCS= +SUPPORTS_NATIVE_M68K=no +if MACHINE=`uname -s 2>/dev/null`; then case "$MACHINE" in Linux*) - SYSSRCS="Linux/ether_linux.cpp Linux/scsi_linux.cpp audio_oss_esd.cpp" + ETHERSRC=Linux/ether_linux.cpp + SCSISRC=Linux/scsi_linux.cpp + AUDIOSRC=audio_oss_esd.cpp ;; FreeBSD*3.*) + AUDIOSRC=audio_oss_esd.cpp + DEFINES="$DEFINES -DBSD_COMP" echo $ac_n "checking for cam_open_btl in -lcam""... $ac_c" 1>&6 -echo "configure:3827: checking for cam_open_btl in -lcam" >&5 +echo "configure:3970: checking for cam_open_btl in -lcam" >&5 ac_lib_var=`echo cam'_'cam_open_btl | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3831,7 +3974,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lcam $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3989: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3864,21 +4007,21 @@ HAVE_LIBCAM=no fi if [ "x$HAVE_LIBCAM" = "xno" ]; then - { echo "configure: error: Cannot find libcam for SCSI management." 1>&2; exit 1; } + echo "configure: warning: Cannot find libcam for SCSI management, disabling SCSI support." 1>&2 else ac_safe=`echo "/sys/cam/cam.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for /sys/cam/cam.h""... $ac_c" 1>&6 -echo "configure:3872: checking for /sys/cam/cam.h" >&5 +echo "configure:4015: checking for /sys/cam/cam.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3882: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4025: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3900,18 +4043,20 @@ else fi if [ "x$ac_cv_header__sys_cam_cam_h" = "xno" ]; then - { echo "configure: error: Cannot find kernel includes for CAM library." 1>&2; exit 1; } + echo "configure: warning: Cannot find kernel includes for CAM library, disabling SCSI support." 1>&2 + else + SCSISRC=FreeBSD/scsi_freebsd.cpp + CXXFLAGS="$CXXFLAGS -I/sys" + CFLAGS="$CFLAGS -I/sys" + LIBS="$LIBS -lcam" + DEFINES="$DEFINES -DCAM" fi - SYSSRCS="../dummy/ether_dummy.cpp FreeBSD/scsi_freebsd.cpp audio_oss_esd.cpp" - CXXFLAGS="$CXXFLAGS -I/sys" - CFLAGS="$CFLAGS -I/sys" - LIBS="$LIBS -lcam" - DEFINES="$DEFINES -DBSD_COMP -DCAM" fi ;; FreeBSD*) + DEFINES="$DEFINES -DBSD_COMP" echo $ac_n "checking for scsi_open in -lscsi""... $ac_c" 1>&6 -echo "configure:3915: checking for scsi_open in -lscsi" >&5 +echo "configure:4060: checking for scsi_open in -lscsi" >&5 ac_lib_var=`echo scsi'_'scsi_open | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3919,7 +4064,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lscsi $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4079: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3952,21 +4097,21 @@ HAVE_LIBSCSI=no fi if [ "x$HAVE_LIBSCSI" = "xno" ]; then - { echo "configure: error: Cannot find libscsi for SCSI management." 1>&2; exit 1; } + echo "configure: warning: Cannot find libscsi for SCSI management, disabling SCSI support." 1>&2 else ac_safe=`echo "scsi.h sys/scsiio.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for scsi.h sys/scsiio.h""... $ac_c" 1>&6 -echo "configure:3960: checking for scsi.h sys/scsiio.h" >&5 +echo "configure:4105: checking for scsi.h sys/scsiio.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3970: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4115: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3988,75 +4133,38 @@ else fi if [ "x$ac_cv_header_scsi_h" = "xno" ]; then - { echo "configure: error: Cannot find includes for the SCSI library." 1>&2; exit 1; } + echo "configure: warning: Cannot find includes for the SCSI library, disabling SCSI support." 1>&2 + else + SCSISRC=FreeBSD/scsi_freebsd.cpp + LIBS="$LIBS -lscsi" fi - SYSSRCS="../dummy/ether_dummy.cpp FreeBSD/scsi_freebsd.cpp ../dummy/audio_dummy.cpp" - LIBS="$LIBS -lscsi" - DEFINES="$DEFINES -DBSD_COMP" fi ;; + NetBSD*) + SUPPORTS_NATIVE_M68K=yes + ;; SunOS*) - SYSSRCS="../dummy/ether_dummy.cpp ../dummy/scsi_dummy.cpp Solaris/audio_solaris.cpp" + AUDIOSRC=Solaris/audio_solaris.cpp DEFINES="$DEFINES -DBSD_COMP -D_POSIX_PTHREAD_SEMANTICS" ;; IRIX*) - SYSSRCS="../dummy/ether_dummy.cpp ../dummy/scsi_dummy.cpp ../dummy/audio_dummy.cpp Irix/unaligned.c" + EXTRASYSSRCS=Irix/unaligned.c DEFINES="$DEFINES -DCRTSCTS=CNEW_RTSCTS -DB230400=B115200" LIBS="$LIBS -lm" ;; esac fi -SYSSRCS="$SYSSRCS $SEMSRCS $UISRCS $MONSRCS" - -HAVE_I386=no -echo $ac_n "checking for x86 target CPU""... $ac_c" 1>&6 -echo "configure:4014: checking for x86 target CPU" >&5 -cat > conftest.$ac_ext <&5 | - egrep "yes" >/dev/null 2>&1; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6; HAVE_I386=yes -else - rm -rf conftest* - echo "$ac_t""no" 1>&6 +if [ "x$HAVE_PTHREADS" = "xno" ]; then + echo "configure: warning: You don't have pthreads, disabling serial, ethernet and audio support." 1>&2 + SERIALSRC=../dummy/serial_dummy.cpp + ETHERSRC=../dummy/ether_dummy.cpp + AUDIOSRC=../dummy/audio_dummy.cpp fi -rm -f conftest* - - -HAVE_SPARC=no -echo $ac_n "checking for SPARC target CPU""... $ac_c" 1>&6 -echo "configure:4037: checking for SPARC target CPU" >&5 -cat > conftest.$ac_ext <&5 | - egrep "yes" >/dev/null 2>&1; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6; HAVE_SPARC=yes -else - rm -rf conftest* - echo "$ac_t""no" 1>&6 -fi -rm -f conftest* - +SYSSRCS="$SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS" HAVE_GAS=no echo $ac_n "checking for GAS .p2align feature""... $ac_c" 1>&6 -echo "configure:4060: checking for GAS .p2align feature" >&5 +echo "configure:4168: checking for GAS .p2align feature" >&5 cat >conftest.S << EOF .text .p2align 5 @@ -4066,9 +4174,9 @@ echo "$ac_t""$HAVE_GAS" 1>&6 HAVE_GCC27=no echo $ac_n "checking for GCC 2.7 or higher""... $ac_c" 1>&6 -echo "configure:4070: checking for GCC 2.7 or higher" >&5 +echo "configure:4178: checking for GCC 2.7 or higher" >&5 cat > conftest.$ac_ext < 1 || __GNUC_MINOR__ - 1 > 5 yes @@ -4086,7 +4194,7 @@ fi rm -f conftest* -if [ "x$HAVE_GCC27" = "xyes" ]; then +if [ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]; then CFLAGS="$CFLAGS -fomit-frame-pointer" CXXFLAGS="$CXXFLAGS -fomit-frame-pointer" fi @@ -4094,6 +4202,7 @@ fi WANT_X86_ASSEMBLY=no WANT_SPARC_V8_ASSEMBLY=no WANT_SPARC_V9_ASSEMBLY=no +WANT_NATIVE_M68K=no CPUSRCS="cpuemu1.cpp cpuemu2.cpp cpuemu3.cpp cpuemu4.cpp cpuemu5.cpp cpuemu6.cpp cpuemu7.cpp cpuemu8.cpp" if [ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]; then DEFINES="$DEFINES -DREGPARAM=\"__attribute__((regparm(3)))\"" @@ -4106,7 +4215,7 @@ elif [ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_SPARC" = "xyes" -a "x$HAVE_GAS" = "xye case "$MACHINE" in SunOS*) echo $ac_n "checking SPARC CPU architecture""... $ac_c" 1>&6 -echo "configure:4110: checking SPARC CPU architecture" >&5 +echo "configure:4219: checking SPARC CPU architecture" >&5 SPARC_TYPE=`Solaris/which_sparc` echo "$ac_t""$SPARC_TYPE" 1>&6 case "$SPARC_TYPE" in @@ -4125,10 +4234,22 @@ echo "configure:4110: checking SPARC CPU architecture" >&5 esac ;; esac +elif [ "x$HAVE_M68K" = "xyes" -a "x$SUPPORTS_NATIVE_M68K" = "xyes" ]; then + CPUSRCS="" + cat >> confdefs.h <<\EOF +#define ENABLE_NATIVE_M68K 1 +EOF + + WANT_NATIVE_M68K=yes fi -CPUINCLUDES="-I../uae_cpu" -CPUSRCS="../uae_cpu/basilisk_glue.cpp ../uae_cpu/memory.cpp ../uae_cpu/newcpu.cpp ../uae_cpu/readcpu.cpp ../uae_cpu/fpp.cpp cpustbl.cpp cpudefs.cpp $CPUSRCS" +if [ "x$WANT_NATIVE_M68K" = "xno" ]; then + CPUINCLUDES="-I../cpu_cpu" + CPUSRCS="../uae_cpu/basilisk_glue.cpp ../uae_cpu/memory.cpp ../uae_cpu/newcpu.cpp ../uae_cpu/readcpu.cpp ../uae_cpu/fpp.cpp cpustbl.cpp cpudefs.cpp $CPUSRCS" +else + CPUINCLUDES="-I../native_cpu" + CPUSRCS="asm_support.s" +fi @@ -4520,5 +4641,6 @@ echo mon debugger support ............. : $WANT_MON echo i386 assembly optimizations ...... : $WANT_X86_ASSEMBLY echo SPARC V8 assembly optimizations .. : $WANT_SPARC_V8_ASSEMBLY echo SPARC V9 assembly optimizations .. : $WANT_SPARC_V9_ASSEMBLY +echo Running m68k code natively ....... : $WANT_NATIVE_M68K echo -echo "Configuration done. Now type \"make\"." +echo "Configuration done. Now type \"make\" (or \"gmake\")." diff --git a/BasiliskII/src/Unix/configure.in b/BasiliskII/src/Unix/configure.in index 61b6c99f..b303eea9 100644 --- a/BasiliskII/src/Unix/configure.in +++ b/BasiliskII/src/Unix/configure.in @@ -20,22 +20,52 @@ AC_PROG_CXX AC_PROG_MAKE_SET AC_PROG_INSTALL +dnl Check for i386 target CPU. +HAVE_I386=no +AC_MSG_CHECKING(for x86 target CPU) +AC_EGREP_CPP(yes, +[ +#ifdef __i386__ + yes +#endif +], [AC_MSG_RESULT(yes); HAVE_I386=yes], AC_MSG_RESULT(no)) + +dnl Check for SPARC target CPU. +HAVE_SPARC=no +AC_MSG_CHECKING(for SPARC target CPU) +AC_EGREP_CPP(yes, +[ +#ifdef __sparc__ + yes +#endif +], [AC_MSG_RESULT(yes); HAVE_SPARC=yes], AC_MSG_RESULT(no)) + +dnl Check for m68k target CPU. +HAVE_M68K=no +AC_MSG_CHECKING(for m68k target CPU) +AC_EGREP_CPP(yes, +[ +#ifdef __m68k__ + yes +#endif +], [AC_MSG_RESULT(yes); HAVE_M68K=yes], AC_MSG_RESULT(no)) + dnl We use mon if possible. MONSRCS= if [[ "x$WANT_MON" = "xyes" ]]; then AC_MSG_CHECKING(for mon) if grep mon_init ../../../mon/src/mon.h >/dev/null 2>/dev/null; then AC_MSG_RESULT(yes) - DEFINES="$DEFINES -DENABLE_MON=1" + AC_DEFINE(ENABLE_MON) MONSRCS="../../../mon/src/mon.cpp ../../../mon/src/mon_6502.cpp ../../../mon/src/mon_68k.cpp ../../../mon/src/mon_8080.cpp ../../../mon/src/mon_cmd.cpp ../../../mon/src/mon_ppc.cpp ../../../mon/src/mon_x86.cpp" CXXFLAGS="$CXXFLAGS -I../../../mon/src" AC_CHECK_LIB(readline, readline) - AC_CHECK_HEADERS(readline/readline.h readline/history.h) + AC_CHECK_LIB(termcap, tputs) + AC_CHECK_HEADERS(readline.h history.h readline/readline.h readline/history.h) else AC_MSG_RESULT(no) AC_MSG_WARN([Could not find mon, ignoring --with-mon.]) WANT_MON=no - DEFINES="$DEFINES -DENABLE_MON=0" fi fi @@ -51,25 +81,32 @@ CFLAGS="$CFLAGS $X_CFLAGS" CXXFLAGS="$CXXFLAGS $X_CFLAGS" LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS" -dnl We need pthreads. Try libpthread first, then libc_r (FreeBSD), then PTL. +dnl We want pthreads. Try libpthread first, then libc_r (FreeBSD), then PTL. +HAVE_PTHREADS=yes AC_CHECK_LIB(pthread, pthread_create, , [ AC_CHECK_LIB(c_r, pthread_create, , [ AC_CHECK_LIB(PTL, pthread_create, , [ - AC_MSG_ERROR([You need pthreads to run Basilisk II.]) + HAVE_PTHREADS=no ]) ]) ]) +if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then + AC_DEFINE(HAVE_PTHREADS) +fi +AC_CHECK_FUNCS(pthread_cancel) dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes. -SEMSRCS= +SEMSRC= AC_CHECK_FUNCS(sem_init, , [ - SEMSRCS=posix_sem.cpp + if [ "x$HAVE_PTHREADS" = "xyes" ]; then + SEMSRC=posix_sem.cpp + fi ]) dnl We use DGA (XFree86 or fbdev) if possible. if [[ "x$WANT_XF86_DGA" = "xyes" ]]; then AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension, [ - DEFINES="$DEFINES -DENABLE_XF86_DGA=1" + AC_DEFINE(ENABLE_XF86_DGA) LIBS="$LIBS -lXxf86dga" if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then AC_MSG_WARN([Cannot have both --enable-xf86-dga and --enable-fbdev-dga, ignoring --enable-fbdev-dga.]) @@ -78,26 +115,20 @@ if [[ "x$WANT_XF86_DGA" = "xyes" ]]; then ], [ AC_MSG_WARN([Could not find XFree86 DGA extension, ignoring --enable-xf86-dga.]) WANT_XF86_DGA=no - DEFINES="$DEFINES -DENABLE_XF86_DGA=0" ]) -else - DEFINES="$DEFINES -DENABLE_XF86_DGA=0" fi if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then - DEFINES="$DEFINES -DENABLE_FBDEV_DGA=1" -else - DEFINES="$DEFINES -DENABLE_FBDEV_DGA=0" + AC_DEFINE(ENABLE_FBDEV_DGA) fi dnl We use XFree86 VidMode if possible. if [[ "x$WANT_XF86_VIDMODE" = "xyes" ]]; then AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, [ - DEFINES="$DEFINES -DENABLE_XF86_VIDMODE=1" + AC_DEFINE(ENABLE_XF86_VIDMODE) LIBS="$LIBS -lXxf86vm" ], [ AC_MSG_WARN([Could not find XFree86 VidMode extension, ignoring --enable-xf86-vidmode.]) WANT_XF86_VIDMODE=no - DEFINES="$DEFINES -DENABLE_XF86_VIDMODE=0" ]) fi @@ -105,7 +136,7 @@ dnl We use GTK+ if possible. UISRCS=../dummy/prefs_editor_dummy.cpp if [[ "x$WANT_GTK" = "xyes" ]]; then AM_PATH_GTK(1.2.0, [ - DEFINES="$DEFINES -DENABLE_GTK=1" + AC_DEFINE(ENABLE_GTK) CFLAGS="$CFLAGS $GTK_CFLAGS" CXXFLAGS="$CXXFLAGS $GTK_CFLAGS" LIBS="$LIBS $GTK_LIBS" @@ -113,21 +144,19 @@ if [[ "x$WANT_GTK" = "xyes" ]]; then ], [ AC_MSG_WARN([Could not find GTK+, disabling user interface.]) WANT_GTK=no - DEFINES="$DEFINES -DENABLE_GTK=0" ]) fi dnl We use ESD if possible. if [[ "x$WANT_ESD" = "xyes" ]]; then AM_PATH_ESD(0.2.8, [ - DEFINES="$DEFINES -DENABLE_ESD=1" + AC_DEFINE(ENABLE_ESD) CFLAGS="$CFLAGS $ESD_CFLAGS" CXXFLAGS="$CXXFLAGS $ESD_CFLAGS" LIBS="$LIBS $ESD_LIBS" ], [ AC_MSG_WARN([Could not find ESD, disabling ESD support.]) WANT_ESD=no - DEFINES="$DEFINES -DENABLE_ESD=0" ]) fi @@ -152,83 +181,83 @@ AC_STRUCT_TM dnl Checks for library functions. AC_CHECK_FUNCS(strdup cfmakeraw) AC_CHECK_FUNCS(nanosleep clock_gettime timer_create) -AC_CHECK_FUNCS(pthread_cancel) dnl Select system-dependant source files. -SYSSRCS="../dummy/ether_dummy.cpp ../dummy/scsi_dummy.cpp ../dummy/audio_dummy.cpp" -if MACHINE=`uname -a 2>/dev/null`; then +SERIALSRC=serial_unix.cpp +ETHERSRC=../dummy/ether_dummy.cpp +SCSISRC=../dummy/scsi_dummy.cpp +AUDIOSRC=../dummy/audio_dummy.cpp +EXTRASYSSRCS= +SUPPORTS_NATIVE_M68K=no +if MACHINE=`uname -s 2>/dev/null`; then case "$MACHINE" in Linux*) - SYSSRCS="Linux/ether_linux.cpp Linux/scsi_linux.cpp audio_oss_esd.cpp" + ETHERSRC=Linux/ether_linux.cpp + SCSISRC=Linux/scsi_linux.cpp + AUDIOSRC=audio_oss_esd.cpp ;; FreeBSD*3.*) + AUDIOSRC=audio_oss_esd.cpp + DEFINES="$DEFINES -DBSD_COMP" dnl Check for the CAM library AC_CHECK_LIB(cam, cam_open_btl, HAVE_LIBCAM=yes, HAVE_LIBCAM=no) if [[ "x$HAVE_LIBCAM" = "xno" ]]; then - AC_MSG_ERROR([Cannot find libcam for SCSI management.]) + AC_MSG_WARN([Cannot find libcam for SCSI management, disabling SCSI support.]) else dnl Check for the sys kernel includes AC_CHECK_HEADER(/sys/cam/cam.h) if [[ "x$ac_cv_header__sys_cam_cam_h" = "xno" ]]; then dnl In this case I should fix this thing including a "patch" dnl to access directly to the functions in the kernel :) --Orlando - AC_MSG_ERROR([Cannot find kernel includes for CAM library.]) + AC_MSG_WARN([Cannot find kernel includes for CAM library, disabling SCSI support.]) + else + SCSISRC=FreeBSD/scsi_freebsd.cpp + CXXFLAGS="$CXXFLAGS -I/sys" + CFLAGS="$CFLAGS -I/sys" + LIBS="$LIBS -lcam" + DEFINES="$DEFINES -DCAM" fi - SYSSRCS="../dummy/ether_dummy.cpp FreeBSD/scsi_freebsd.cpp audio_oss_esd.cpp" - CXXFLAGS="$CXXFLAGS -I/sys" - CFLAGS="$CFLAGS -I/sys" - LIBS="$LIBS -lcam" - DEFINES="$DEFINES -DBSD_COMP -DCAM" fi ;; FreeBSD*) + DEFINES="$DEFINES -DBSD_COMP" dnl Check for the SCSI library AC_CHECK_LIB(scsi, scsi_open, HAVE_LIBSCSI=yes, HAVE_LIBSCSI=no) if [[ "x$HAVE_LIBSCSI" = "xno" ]]; then - AC_MSG_ERROR([Cannot find libscsi for SCSI management.]) + AC_MSG_WARN([Cannot find libscsi for SCSI management, disabling SCSI support.]) else dnl Check for the sys kernel includes AC_CHECK_HEADER(scsi.h sys/scsiio.h) if [[ "x$ac_cv_header_scsi_h" = "xno" ]]; then - AC_MSG_ERROR([Cannot find includes for the SCSI library.]) + AC_MSG_WARN([Cannot find includes for the SCSI library, disabling SCSI support.]) + else + SCSISRC=FreeBSD/scsi_freebsd.cpp + LIBS="$LIBS -lscsi" fi - SYSSRCS="../dummy/ether_dummy.cpp FreeBSD/scsi_freebsd.cpp ../dummy/audio_dummy.cpp" - LIBS="$LIBS -lscsi" - DEFINES="$DEFINES -DBSD_COMP" fi ;; + NetBSD*) + SUPPORTS_NATIVE_M68K=yes + ;; SunOS*) - SYSSRCS="../dummy/ether_dummy.cpp ../dummy/scsi_dummy.cpp Solaris/audio_solaris.cpp" + AUDIOSRC=Solaris/audio_solaris.cpp DEFINES="$DEFINES -DBSD_COMP -D_POSIX_PTHREAD_SEMANTICS" ;; IRIX*) - SYSSRCS="../dummy/ether_dummy.cpp ../dummy/scsi_dummy.cpp ../dummy/audio_dummy.cpp Irix/unaligned.c" + EXTRASYSSRCS=Irix/unaligned.c DEFINES="$DEFINES -DCRTSCTS=CNEW_RTSCTS -DB230400=B115200" LIBS="$LIBS -lm" ;; esac fi -SYSSRCS="$SYSSRCS $SEMSRCS $UISRCS $MONSRCS" - -dnl Check for i386 CPU. -HAVE_I386=no -AC_MSG_CHECKING(for x86 target CPU) -AC_EGREP_CPP(yes, -[ -#ifdef __i386__ - yes -#endif -], [AC_MSG_RESULT(yes); HAVE_I386=yes], AC_MSG_RESULT(no)) - -dnl Check for SPARC CPU. -HAVE_SPARC=no -AC_MSG_CHECKING(for SPARC target CPU) -AC_EGREP_CPP(yes, -[ -#ifdef __sparc__ - yes -#endif -], [AC_MSG_RESULT(yes); HAVE_SPARC=yes], AC_MSG_RESULT(no)) +if [[ "x$HAVE_PTHREADS" = "xno" ]]; then + dnl Serial, ethernet and audio support needs pthreads + AC_MSG_WARN([You don't have pthreads, disabling serial, ethernet and audio support.]) + SERIALSRC=../dummy/serial_dummy.cpp + ETHERSRC=../dummy/ether_dummy.cpp + AUDIOSRC=../dummy/audio_dummy.cpp +fi +SYSSRCS="$SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS" dnl Check for GAS. HAVE_GAS=no @@ -249,8 +278,8 @@ AC_EGREP_CPP(yes, #endif ], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no)) -dnl Set "-fomit-frame-pointer" on GCC 2.7 or higher. -if [[ "x$HAVE_GCC27" = "xyes" ]]; then +dnl Set "-fomit-frame-pointer" on i386 GCC 2.7 or higher. +if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then CFLAGS="$CFLAGS -fomit-frame-pointer" CXXFLAGS="$CXXFLAGS -fomit-frame-pointer" fi @@ -259,6 +288,7 @@ dnl Select appropriate CPU source and REGPARAM define. WANT_X86_ASSEMBLY=no WANT_SPARC_V8_ASSEMBLY=no WANT_SPARC_V9_ASSEMBLY=no +WANT_NATIVE_M68K=no CPUSRCS="cpuemu1.cpp cpuemu2.cpp cpuemu3.cpp cpuemu4.cpp cpuemu5.cpp cpuemu6.cpp cpuemu7.cpp cpuemu8.cpp" if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then dnl i386 CPU @@ -291,11 +321,21 @@ elif [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_SPARC" = "xyes" -a "x$HAVE_GAS" = "xy esac ;; esac +elif [[ "x$HAVE_M68K" = "xyes" -a "x$SUPPORTS_NATIVE_M68K" = "xyes" ]]; then + dnl Native m68k, no emulation + CPUSRCS="" + AC_DEFINE(ENABLE_NATIVE_M68K) + WANT_NATIVE_M68K=yes fi -dnl UAE CPU sources for all architectures. -CPUINCLUDES="-I../uae_cpu" -CPUSRCS="../uae_cpu/basilisk_glue.cpp ../uae_cpu/memory.cpp ../uae_cpu/newcpu.cpp ../uae_cpu/readcpu.cpp ../uae_cpu/fpp.cpp cpustbl.cpp cpudefs.cpp $CPUSRCS" +dnl UAE CPU sources for all non-m68k-native architectures. +if [[ "x$WANT_NATIVE_M68K" = "xno" ]]; then + CPUINCLUDES="-I../cpu_cpu" + CPUSRCS="../uae_cpu/basilisk_glue.cpp ../uae_cpu/memory.cpp ../uae_cpu/newcpu.cpp ../uae_cpu/readcpu.cpp ../uae_cpu/fpp.cpp cpustbl.cpp cpudefs.cpp $CPUSRCS" +else + CPUINCLUDES="-I../native_cpu" + CPUSRCS="asm_support.s" +fi dnl Generate Makefile. AC_SUBST(DEFINES) @@ -317,5 +357,6 @@ echo mon debugger support ............. : $WANT_MON echo i386 assembly optimizations ...... : $WANT_X86_ASSEMBLY echo SPARC V8 assembly optimizations .. : $WANT_SPARC_V8_ASSEMBLY echo SPARC V9 assembly optimizations .. : $WANT_SPARC_V9_ASSEMBLY +echo Running m68k code natively ....... : $WANT_NATIVE_M68K echo -echo "Configuration done. Now type \"make\"." +echo "Configuration done. Now type \"make\" (or \"gmake\")." diff --git a/BasiliskII/src/Unix/main_unix.cpp b/BasiliskII/src/Unix/main_unix.cpp index 584f589d..fe0d4fe2 100644 --- a/BasiliskII/src/Unix/main_unix.cpp +++ b/BasiliskII/src/Unix/main_unix.cpp @@ -22,8 +22,40 @@ #include #include -#include #include +#include +#include + +#ifdef HAVE_PTHREADS +# include +#endif + +#if defined(USE_MAPPED_MEMORY) || REAL_ADDRESSING +# include +#endif + +#if !EMULATED_68K && defined(__NetBSD__) +# include +# include +# include +# include +struct sigstate { + int ss_flags; + struct frame ss_frame; + struct fpframe ss_fpstate; +}; +# define SS_FPSTATE 0x02 +# define SS_USERREGS 0x04 +#endif + +#ifdef ENABLE_GTK +# include +#endif + +#ifdef ENABLE_XF86_DGA +# include +# include +#endif #include "cpu_emulation.h" #include "sys.h" @@ -31,6 +63,7 @@ #include "xpram.h" #include "timer.h" #include "video.h" +#include "emul_op.h" #include "prefs.h" #include "prefs_editor.h" #include "macos_util.h" @@ -38,34 +71,29 @@ #include "version.h" #include "main.h" -#define DEBUG 0 +#ifdef ENABLE_MON +# include "mon.h" +#endif + +#define DEBUG 1 #include "debug.h" -#include - -#if ENABLE_GTK -#include -#endif - -#if ENABLE_XF86_DGA -#include -#include -#include -#endif - -#if ENABLE_MON -#include "mon.h" -#endif - -#ifdef USE_MAPPED_MEMORY -#include -extern char *address_space, *good_address_map; -#endif - - // Constants const char ROM_FILE_NAME[] = "ROM"; +const int SIG_STACK_SIZE = SIGSTKSZ; // Size of signal stack +const int SCRATCH_MEM_SIZE = 0x10000; // Size of scratch memory area + + +#if !EMULATED_68K +// RAM and ROM pointers +uint32 RAMBaseMac; // RAM base (Mac address space) +uint8 *RAMBaseHost; // RAM base (host address space) +uint32 RAMSize; // Size of RAM +uint32 ROMBaseMac; // ROM base (Mac address space) +uint8 *ROMBaseHost; // ROM base (host address space) +uint32 ROMSize; // Size of ROM +#endif // CPU and FPU type, addressing mode @@ -79,6 +107,13 @@ bool TwentyFourBitAddressing; static char *x_display_name = NULL; // X11 display name Display *x_display = NULL; // X11 display handle +static int zero_fd = -1; // FD of /dev/zero +static bool lm_area_mapped = false; // Flag: Low Memory area mmap()ped +static uint8 last_xpram[256]; // Buffer for monitoring XPRAM changes + +#ifdef HAVE_PTHREADS +static pthread_t emul_thread; // Handle of MacOS emulation thread (main thread) + static bool xpram_thread_active = false; // Flag: XPRAM watchdog installed static volatile bool xpram_thread_cancel = false; // Flag: Cancel XPRAM thread static pthread_t xpram_thread; // XPRAM watchdog @@ -88,24 +123,46 @@ static volatile bool tick_thread_cancel = false; // Flag: Cancel 60Hz thread static pthread_t tick_thread; // 60Hz thread static pthread_attr_t tick_thread_attr; // 60Hz thread attributes +#if EMULATED_68K static pthread_mutex_t intflag_lock = PTHREAD_MUTEX_INITIALIZER; // Mutex to protect InterruptFlags +#endif +#endif + +#if !EMULATED_68K +#define SIG_IRQ SIGUSR1 +static struct sigaction sigirq_sa; // Virtual 68k interrupt signal +static struct sigaction sigill_sa; // Illegal instruction +static void *sig_stack = NULL; // Stack for signal handlers +uint16 EmulatedSR; // Emulated bits of SR (supervisor bit and interrupt mask) +uint32 ScratchMem = NULL; // Scratch memory for Mac ROM writes +#endif + +static struct sigaction timer_sa; // sigaction used for timer #if defined(HAVE_TIMER_CREATE) && defined(_POSIX_REALTIME_SIGNALS) #define SIG_TIMER SIGRTMIN -static struct sigaction timer_sa; // sigaction used for timer -static timer_t timer; // 60Hz timer +static timer_t timer; // 60Hz timer #endif -#if ENABLE_MON -static struct sigaction sigint_sa; // sigaction for SIGINT handler +#ifdef ENABLE_MON +static struct sigaction sigint_sa; // sigaction for SIGINT handler static void sigint_handler(...); #endif +#ifdef USE_MAPPED_MEMORY +extern char *address_space, *good_address_map; +#endif + // Prototypes static void *xpram_func(void *arg); static void *tick_func(void *arg); static void one_tick(...); +#if !EMULATED_68K +static void sigirq_handler(int sig, int code, struct sigcontext *scp); +static void sigill_handler(int sig, int code, struct sigcontext *scp); +extern "C" void EmulOpTrampoline(void); +#endif /* @@ -132,6 +189,8 @@ char *strdup(const char *s) int main(int argc, char **argv) { + char str[256]; + // Initialize variables RAMBaseHost = NULL; ROMBaseHost = NULL; @@ -161,12 +220,12 @@ int main(int argc, char **argv) QuitEmulator(); } -#if ENABLE_XF86_DGA && !ENABLE_MON +#if defined(ENABLE_XF86_DGA) && !defined(ENABLE_MON) // Fork out, so we can return from fullscreen mode when things get ugly XF86DGAForkApp(DefaultScreen(x_display)); #endif -#if ENABLE_GTK +#ifdef ENABLE_GTK // Init GTK gtk_set_locale(); gtk_init(&argc, &argv); @@ -183,6 +242,14 @@ int main(int argc, char **argv) if (!PrefsEditor()) QuitEmulator(); + // Open /dev/zero + zero_fd = open("/dev/zero", O_RDWR); + if (zero_fd < 0) { + sprintf(str, GetString(STR_NO_DEV_ZERO_ERR), strerror(errno)); + ErrorAlert(str); + QuitEmulator(); + } + // Read RAM size RAMSize = PrefsFindInt32("ramsize") & 0xfff00000; // Round down to 1MB boundary if (RAMSize < 1024*1024) { @@ -190,18 +257,36 @@ int main(int argc, char **argv) RAMSize = 1024*1024; } +#if REAL_ADDRESSING + // Create Low Memory area (0x0000..0x2000) + if (mmap((char *)0x0000, 0x2000, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, zero_fd, 0) == (void *)-1) { + sprintf(str, GetString(STR_LOW_MEM_MMAP_ERR), strerror(errno)); + ErrorAlert(str); + QuitEmulator(); + } + lm_area_mapped = true; +#endif + +#if !EMULATED_68K + // Allocate scratch memory + ScratchMem = (uint32)malloc(SCRATCH_MEM_SIZE); + if (ScratchMem == NULL) { + ErrorAlert(GetString(STR_NO_MEM_ERR)); + QuitEmulator(); + } + ScratchMem += SCRATCH_MEM_SIZE/2; // ScratchMem points to middle of block +#endif + // Create areas for Mac RAM and ROM -#ifdef USE_MAPPED_MEMORY - int fd = open("/dev/zero", O_RDWR); - good_address_map = (char *)mmap(NULL, 1<<24, PROT_READ, MAP_PRIVATE, fd, 0); - address_space = (char *)mmap(NULL, 1<<24, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); +#if defined(USE_MAPPED_MEMORY) + good_address_map = (char *)mmap(NULL, 1<<24, PROT_READ, MAP_PRIVATE, zero_fd, 0); + address_space = (char *)mmap(NULL, 1<<24, PROT_READ | PROT_WRITE, MAP_PRIVATE, zero_fd, 0); if ((int)address_space < 0 || (int)good_address_map < 0) { ErrorAlert(GetString(STR_NOT_ENOUGH_MEMORY_ERR)); QuitEmulator(); } - RAMBaseHost = (uint8 *)mmap(address_space, RAMSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, 0); - ROMBaseHost = (uint8 *)mmap(address_space + 0x00400000, 0x80000, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, 0); - close(fd); + RAMBaseHost = (uint8 *)mmap(address_space, RAMSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, zero_fd, 0); + ROMBaseHost = (uint8 *)mmap(address_space + 0x00400000, 0x80000, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, zero_fd, 0); char *nam = tmpnam(NULL); int good_address_fd = open(nam, O_CREAT | O_RDWR, 0600); char buffer[4096]; @@ -216,6 +301,12 @@ int main(int argc, char **argv) RAMBaseHost = new uint8[RAMSize]; ROMBaseHost = new uint8[0x100000]; #endif +#if REAL_ADDRESSING && !EMULATED_68K + RAMBaseMac = (uint32)RAMBaseHost; + ROMBaseMac = (uint32)ROMBaseHost; +#endif + D(bug("Mac RAM starts at %p (%08x)\n", RAMBaseHost, RAMBaseMac)); + D(bug("Mac ROM starts at %p (%08x)\n", ROMBaseHost, ROMBaseMac)); // Get rom file path from preferences const char *rom_path = PrefsFindString("rom"); @@ -240,27 +331,116 @@ int main(int argc, char **argv) QuitEmulator(); } +#if !EMULATED_68K + // Get CPU model + int mib[2] = {CTL_HW, HW_MODEL}; + char *model; + size_t model_len; + sysctl(mib, 2, NULL, &model_len, NULL, 0); + model = (char *)malloc(model_len); + sysctl(mib, 2, model, &model_len, NULL, 0); + D(bug("Model: %s\n", model)); + + // Set CPU and FPU type + CPUIs68060 = false; + if (strstr(model, "020")) + CPUType = 2; + else if (strstr(model, "030")) + CPUType = 3; + else if (strstr(model, "040")) + CPUType = 4; + else if (strstr(model, "060")) { + CPUType = 4; + CPUIs68060 = true; + } else { + printf("WARNING: Cannot detect CPU type, assuming 68020\n"); + CPUType = 2; + } + FPUType = 0; //!! + TwentyFourBitAddressing = false; +#endif + // Initialize everything if (!InitAll()) QuitEmulator(); + D(bug("Initialization complete\n")); - // Start XPRAM watchdog thread - xpram_thread_active = (pthread_create(&xpram_thread, NULL, xpram_func, NULL) == 0); +#ifdef HAVE_PTHREADS + // Get handle of main thread + emul_thread = pthread_self(); +#endif + +#if !EMULATED_68K + // (Virtual) supervisor mode, disable interrupts + EmulatedSR = 0x2700; + + // Create and install stack for signal handlers + sig_stack = malloc(SIG_STACK_SIZE); + D(bug("Signal stack at %p\n", sig_stack)); + if (sig_stack == NULL) { + ErrorAlert(GetString(STR_NOT_ENOUGH_MEMORY_ERR)); + QuitEmulator(); + } + stack_t new_stack; + new_stack.ss_sp = sig_stack; + new_stack.ss_flags = 0; + new_stack.ss_size = SIG_STACK_SIZE; + if (sigaltstack(&new_stack, NULL) < 0) { + sprintf(str, GetString(STR_SIGALTSTACK_ERR), strerror(errno)); + ErrorAlert(str); + QuitEmulator(); + } + + // Install SIGILL handler for emulating privileged instructions and + // executing A-Trap and EMUL_OP opcodes + sigemptyset(&sigill_sa.sa_mask); // Block virtual 68k interrupts during SIGILL handling + sigaddset(&sigill_sa.sa_mask, SIG_IRQ); + sigaddset(&sigill_sa.sa_mask, SIGALRM); + sigill_sa.sa_handler = (void (*)(int))sigill_handler; + sigill_sa.sa_flags = SA_ONSTACK; + if (sigaction(SIGILL, &sigill_sa, NULL) < 0) { + sprintf(str, GetString(STR_SIG_INSTALL_ERR), "SIGILL", strerror(errno)); + ErrorAlert(str); + QuitEmulator(); + } + + // Install virtual 68k interrupt signal handler + sigemptyset(&sigirq_sa.sa_mask); + sigaddset(&sigirq_sa.sa_mask, SIGALRM); + sigirq_sa.sa_handler = (void (*)(int))sigirq_handler; + sigirq_sa.sa_flags = SA_ONSTACK | SA_RESTART; + if (sigaction(SIG_IRQ, &sigirq_sa, NULL) < 0) { + sprintf(str, GetString(STR_SIG_INSTALL_ERR), "SIG_IRQ", strerror(errno)); + ErrorAlert(str); + QuitEmulator(); + } +#endif + +#ifdef ENABLE_MON + // Setup SIGINT handler to enter mon + sigemptyset(&sigint_sa.sa_mask); + sigint_sa.sa_handler = sigint_handler; + sigint_sa.sa_flags = 0; + sigaction(SIGINT, &sigint_sa, NULL); +#endif #if defined(HAVE_TIMER_CREATE) && defined(_POSIX_REALTIME_SIGNALS) - // Start 60Hz timer + + // POSIX.4 timers and real-time signals available, start 60Hz timer sigemptyset(&timer_sa.sa_mask); - timer_sa.sa_flags = SA_SIGINFO | SA_RESTART; timer_sa.sa_sigaction = one_tick; + timer_sa.sa_flags = SA_SIGINFO | SA_RESTART; if (sigaction(SIG_TIMER, &timer_sa, NULL) < 0) { - printf("FATAL: cannot set up timer signal handler\n"); + sprintf(str, GetString(STR_SIG_INSTALL_ERR), "SIG_TIMER", strerror(errno)); + ErrorAlert(str); QuitEmulator(); } struct sigevent timer_event; timer_event.sigev_notify = SIGEV_SIGNAL; timer_event.sigev_signo = SIG_TIMER; if (timer_create(CLOCK_REALTIME, &timer_event, &timer) < 0) { - printf("FATAL: cannot create timer\n"); + sprintf(str, GetString(STR_TIMER_CREATE_ERR), strerror(errno)); + ErrorAlert(str); QuitEmulator(); } struct itimerspec req; @@ -269,13 +449,15 @@ int main(int argc, char **argv) req.it_interval.tv_sec = 0; req.it_interval.tv_nsec = 16625000; if (timer_settime(timer, 0, &req, NULL) < 0) { - printf("FATAL: cannot start timer\n"); + sprintf(str, GetString(STR_TIMER_SETTIME_ERR), strerror(errno)); + ErrorAlert(str); QuitEmulator(); } + D(bug("60Hz timer started\n")); -#else +#elif defined(HAVE_PTHREADS) - // Start 60Hz thread + // POSIX threads available, start 60Hz thread pthread_attr_init(&tick_thread_attr); #if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) if (geteuid() == 0) { @@ -288,20 +470,40 @@ int main(int argc, char **argv) #endif tick_thread_active = (pthread_create(&tick_thread, &tick_thread_attr, tick_func, NULL) == 0); if (!tick_thread_active) { - printf("FATAL: cannot create tick thread\n"); + sprintf(str, GetString(STR_TICK_THREAD_ERR), strerror(errno)); + ErrorAlert(str); QuitEmulator(); } + D(bug("60Hz thread started\n")); + +#else + + // Start 60Hz timer + sigemptyset(&timer_sa.sa_mask); // Block virtual 68k interrupts during SIGARLM handling + sigaddset(&timer_sa.sa_mask, SIG_IRQ); + timer_sa.sa_handler = one_tick; + timer_sa.sa_flags = SA_ONSTACK | SA_RESTART; + if (sigaction(SIGALRM, &timer_sa, NULL) < 0) { + sprintf(str, GetString(STR_SIG_INSTALL_ERR), "SIGALRM", strerror(errno)); + ErrorAlert(str); + QuitEmulator(); + } + struct itimerval req; + req.it_interval.tv_sec = req.it_value.tv_sec = 0; + req.it_interval.tv_usec = req.it_value.tv_usec = 16625; + setitimer(ITIMER_REAL, &req, NULL); + #endif -#if ENABLE_MON - // Setup SIGINT handler to enter mon - sigemptyset(&sigint_sa.sa_mask); - sigint_sa.sa_flags = 0; - sigint_sa.sa_handler = sigint_handler; - sigaction(SIGINT, &sigint_sa, NULL); +#ifdef HAVE_PTHREADS + // Start XPRAM watchdog thread + memcpy(last_xpram, XPRAM, 256); + xpram_thread_active = (pthread_create(&xpram_thread, NULL, xpram_func, NULL) == 0); + D(bug("XPRAM thread started\n")); #endif // Start 68k and jump to ROM boot routine + D(bug("Starting emulation...\n")); Start680x0(); QuitEmulator(); @@ -315,13 +517,17 @@ int main(int argc, char **argv) void QuitEmulator(void) { + D(bug("QuitEmulator\n")); + +#if EMULATED_68K // Exit 680x0 emulation Exit680x0(); +#endif #if defined(HAVE_TIMER_CREATE) && defined(_POSIX_REALTIME_SIGNALS) // Stop 60Hz timer timer_delete(timer); -#else +#elif defined(HAVE_PTHREADS) // Stop 60Hz thread if (tick_thread_active) { tick_thread_cancel = true; @@ -330,8 +536,14 @@ void QuitEmulator(void) #endif pthread_join(tick_thread, NULL); } +#else + struct itimerval req; + req.it_interval.tv_sec = req.it_value.tv_sec = 0; + req.it_interval.tv_usec = req.it_value.tv_usec = 0; + setitimer(ITIMER_REAL, &req, NULL); #endif +#ifdef HAVE_PTHREADS // Stop XPRAM watchdog thread if (xpram_thread_active) { xpram_thread_cancel = true; @@ -340,6 +552,7 @@ void QuitEmulator(void) #endif pthread_join(xpram_thread, NULL); } +#endif // Deinitialize everything ExitAll(); @@ -350,6 +563,22 @@ void QuitEmulator(void) // Delete RAM area delete[] RAMBaseHost; +#if !EMULATED_68K + // Delete scratch memory area + if (ScratchMem) + free((void *)(ScratchMem - SCRATCH_MEM_SIZE/2)); +#endif + +#if REAL_ADDRESSING + // Delete Low Memory area + if (lm_area_mapped) + munmap((char *)0x0000, 0x2000); +#endif + + // Close /dev/zero + if (zero_fd > 0) + close(zero_fd); + // Exit system routines SysExit(); @@ -369,26 +598,30 @@ void QuitEmulator(void) * or a dynamically recompiling emulator) */ -#if EMULATED_68K void FlushCodeCache(void *start, uint32 size) { -} +#if !EMULATED_68K && defined(__NetBSD__) + m68k_sync_icache(start, size); #endif +} /* * SIGINT handler, enters mon */ -#if ENABLE_MON -extern void m68k_dumpstate(uaecptr *nextpc); +#ifdef ENABLE_MON static void sigint_handler(...) { +#if EMULATED_68K uaecptr nextpc; + extern void m68k_dumpstate(uaecptr *nextpc); m68k_dumpstate(&nextpc); +#else char *arg[2] = {"rmon", NULL}; mon(1, arg); QuitEmulator(); +#endif } #endif @@ -399,35 +632,104 @@ static void sigint_handler(...) uint32 InterruptFlags = 0; +#if EMULATED_68K void SetInterruptFlag(uint32 flag) { +#ifdef HAVE_PTHREADS pthread_mutex_lock(&intflag_lock); InterruptFlags |= flag; pthread_mutex_unlock(&intflag_lock); +#else + InterruptFlags |= flag; // Pray that this is an atomic operation... +#endif } void ClearInterruptFlag(uint32 flag) { +#ifdef HAVE_PTHREADS pthread_mutex_lock(&intflag_lock); InterruptFlags &= ~flag; pthread_mutex_unlock(&intflag_lock); +#else + InterruptFlags &= ~flag; +#endif } +#endif + +#if !EMULATED_68K +void TriggerInterrupt(void) +{ +#if defined(HAVE_PTHREADS) + pthread_kill(emul_thread, SIG_IRQ); +#else + raise(SIG_IRQ); +#endif +} +#endif + + +/* + * XPRAM watchdog thread (saves XPRAM every minute) + */ + +static void xpram_watchdog(void) +{ + if (memcmp(last_xpram, XPRAM, 256)) { + memcpy(last_xpram, XPRAM, 256); + SaveXPRAM(); + } +} + +#ifdef HAVE_PTHREADS +static void *xpram_func(void *arg) +{ + while (!xpram_thread_cancel) { + for (int i=0; i<60 && !xpram_thread_cancel; i++) { +#ifdef HAVE_NANOSLEEP + struct timespec req = {1, 0}; + nanosleep(&req, NULL); +#else + usleep(1000000); +#endif + } + xpram_watchdog(); + } + return NULL; +} +#endif /* * 60Hz thread (really 60.15Hz) */ +static void one_second(void) +{ + // Pseudo Mac 1Hz interrupt, update local time + WriteMacInt32(0x20c, TimerDateTime()); + +#ifndef HAVE_PTHREADS + static int second_counter = 0; + if (++second_counter > 60) { + second_counter = 0; + xpram_watchdog(); + } +#endif +} + static void one_tick(...) { static int tick_counter = 0; - - // Pseudo Mac 1Hz interrupt, update local time if (++tick_counter > 60) { tick_counter = 0; - WriteMacInt32(0x20c, TimerDateTime()); + one_second(); } +#ifndef HAVE_PTHREADS + // No threads available, perform video refresh from here + VideoRefresh(); +#endif + // Trigger 60Hz interrupt if (ROMVersion != ROM_VERSION_CLASSIC || HasMacStarted()) { SetInterruptFlag(INTFLAG_60HZ); @@ -435,6 +737,7 @@ static void one_tick(...) } } +#ifdef HAVE_PTHREADS static void *tick_func(void *arg) { while (!tick_thread_cancel) { @@ -452,40 +755,294 @@ static void *tick_func(void *arg) } return NULL; } +#endif + + +#if !EMULATED_68K +/* + * Virtual 68k interrupt handler + */ + +static void sigirq_handler(int sig, int code, struct sigcontext *scp) +{ + // Interrupts disabled? Then do nothing + if (EmulatedSR & 0x0700) + return; + + struct sigstate *state = (struct sigstate *)scp->sc_ap; + M68kRegisters *regs = (M68kRegisters *)&state->ss_frame; + + // Set up interrupt frame on stack + uint32 a7 = regs->a[7]; + a7 -= 2; + WriteMacInt16(a7, 0x64); + a7 -= 4; + WriteMacInt32(a7, scp->sc_pc); + a7 -= 2; + WriteMacInt16(a7, scp->sc_ps | EmulatedSR); + scp->sc_sp = regs->a[7] = a7; + + // Set interrupt level + EmulatedSR |= 0x2100; + + // Jump to MacOS interrupt handler on return + scp->sc_pc = ReadMacInt32(0x64); +} /* - * XPRAM watchdog thread (saves XPRAM every minute) + * SIGILL handler, for emulation of privileged instructions and executing + * A-Trap and EMUL_OP opcodes */ -void *xpram_func(void *arg) +static void sigill_handler(int sig, int code, struct sigcontext *scp) { - uint8 last_xpram[256]; - memcpy(last_xpram, XPRAM, 256); + struct sigstate *state = (struct sigstate *)scp->sc_ap; + uint16 *pc = (uint16 *)scp->sc_pc; + uint16 opcode = *pc; + M68kRegisters *regs = (M68kRegisters *)&state->ss_frame; - while (!xpram_thread_cancel) { - for (int i=0; i<60 && !xpram_thread_cancel; i++) { -#ifdef HAVE_NANOSLEEP - struct timespec req = {1, 0}; - nanosleep(&req, NULL); -#else - usleep(1000000); +#define INC_PC(n) scp->sc_pc += (n) + +#define GET_SR (scp->sc_ps | EmulatedSR) + +#define STORE_SR(v) \ + scp->sc_ps = (v) & 0xff; \ + EmulatedSR = (v) & 0x2700; \ + if (((v) & 0x0700) == 0 && InterruptFlags) \ + TriggerInterrupt(); + +//printf("opcode %04x at %p, sr %04x, emul_sr %04x\n", opcode, pc, scp->sc_ps, EmulatedSR); + + if ((opcode & 0xf000) == 0xa000) { + + // A-Line instruction, set up A-Line trap frame on stack + uint32 a7 = regs->a[7]; + a7 -= 2; + WriteMacInt16(a7, 0x28); + a7 -= 4; + WriteMacInt32(a7, (uint32)pc); + a7 -= 2; + WriteMacInt16(a7, GET_SR); + scp->sc_sp = regs->a[7] = a7; + + // Jump to MacOS A-Line handler on return + scp->sc_pc = ReadMacInt32(0x28); + + } else if ((opcode & 0xff00) == 0x7100) { + + // Extended opcode, push registers on user stack + uint32 a7 = regs->a[7]; + a7 -= 4; + WriteMacInt32(a7, (uint32)pc); + a7 -= 2; + WriteMacInt16(a7, scp->sc_ps); + for (int i=7; i>=0; i--) { + a7 -= 4; + WriteMacInt32(a7, regs->a[i]); + } + for (int i=7; i>=0; i--) { + a7 -= 4; + WriteMacInt32(a7, regs->d[i]); + } + scp->sc_sp = regs->a[7] = a7; + + // Jump to EmulOp trampoline code on return + scp->sc_pc = (uint32)EmulOpTrampoline; + + } else switch (opcode) { // Emulate privileged instructions + + case 0x40e7: // move sr,-(sp) + regs->a[7] -= 2; + WriteMacInt16(regs->a[7], GET_SR); + scp->sc_sp = regs->a[7]; + INC_PC(2); + break; + + case 0x46df: { // move (sp)+,sr + uint16 sr = ReadMacInt16(regs->a[7]); + STORE_SR(sr); + regs->a[7] += 2; + scp->sc_sp = regs->a[7]; + INC_PC(2); + break; + } + + case 0x007c: { // ori #xxxx,sr + uint16 sr = GET_SR | pc[1]; + scp->sc_ps = sr & 0xff; // oring bits into the sr can't enable interrupts, so we don't need to call STORE_SR + EmulatedSR = sr & 0x2700; + INC_PC(4); + break; + } + + case 0x027c: { // andi #xxxx,sr + uint16 sr = GET_SR & pc[1]; + STORE_SR(sr); + INC_PC(4); + break; + } + + case 0x46fc: // move #xxxx,sr + STORE_SR(pc[1]); + INC_PC(4); + break; + + case 0x46ef: { // move (xxxx,sp),sr + uint16 sr = ReadMacInt16(regs->a[7] + (int32)(int16)pc[1]); + STORE_SR(sr); + INC_PC(4); + break; + } + + case 0x46d8: // move (a0)+,sr + case 0x46d9: { // move (a1)+,sr + uint16 sr = ReadMacInt16(regs->a[opcode & 7]); + STORE_SR(sr); + regs->a[opcode & 7] += 2; + INC_PC(2); + break; + } + + case 0x40f8: // move sr,xxxx.w + WriteMacInt16(pc[1], GET_SR); + INC_PC(4); + break; + + case 0x40d0: // move sr,(a0) + case 0x40d1: // move sr,(a1) + case 0x40d2: // move sr,(a2) + case 0x40d3: // move sr,(a3) + case 0x40d4: // move sr,(a4) + case 0x40d5: // move sr,(a5) + case 0x40d6: // move sr,(a6) + case 0x40d7: // move sr,(sp) + WriteMacInt16(regs->a[opcode & 7], GET_SR); + INC_PC(2); + break; + + case 0x40c0: // move sr,d0 + case 0x40c1: // move sr,d1 + case 0x40c2: // move sr,d2 + case 0x40c3: // move sr,d3 + case 0x40c4: // move sr,d4 + case 0x40c5: // move sr,d5 + case 0x40c6: // move sr,d6 + case 0x40c7: // move sr,d7 + regs->d[opcode & 7] = GET_SR; + INC_PC(2); + break; + + case 0x46c0: // move d0,sr + case 0x46c1: // move d1,sr + case 0x46c2: // move d2,sr + case 0x46c3: // move d3,sr + case 0x46c4: // move d4,sr + case 0x46c5: // move d5,sr + case 0x46c6: // move d6,sr + case 0x46c7: { // move d7,sr + uint16 sr = regs->d[opcode & 7]; + STORE_SR(sr); + INC_PC(2); + break; + } + + case 0xf327: // fsave -(sp) + goto ill; //!! + + case 0xf35f: // frestore (sp)+ + goto ill; //!! + + case 0x4e73: { // rte (only handles format 0) + uint32 a7 = regs->a[7]; + uint16 sr = ReadMacInt16(a7); + a7 += 2; + scp->sc_ps = sr & 0xff; + EmulatedSR = sr & 0x2700; + scp->sc_pc = ReadMacInt32(a7); + a7 += 6; + scp->sc_sp = regs->a[7] = a7; + break; + } + + case 0x4e7a: // movec cr,x + switch (pc[1]) { + case 0x8801: // movec vbr,a0 + regs->a[0] = 0; + break; + case 0x9801: // movec vbr,a1 + regs->a[1] = 0; + break; + case 0x0002: // movec cacr,d0 + regs->d[0] = 0x3111; + break; + case 0x1002: // movec cacr,d1 + regs->d[1] = 0x3111; + break; + case 0x0003: // movec tc,d0 + regs->d[0] = 0; + break; + case 0x1003: // movec tc,d1 + regs->d[1] = 0; + break; + default: + goto ill; + } + INC_PC(4); + break; + + case 0x4e7b: // movec x,cr + switch (pc[1]) { + case 0x0801: // movec d0,vbr + break; + case 0x0002: // movec d0,cacr + case 0x1002: // movec d1,cacr + FlushCodeCache(NULL, 0); + break; + default: + goto ill; + } + INC_PC(4); + break; + + case 0xf478: // cpusha dc + case 0xf4f8: // cpusha dc/ic + FlushCodeCache(NULL, 0); + INC_PC(2); + break; + + default: +ill: printf("SIGILL num %d, code %d\n", sig, code); + printf(" context %p:\n", scp); + printf(" onstack %08x\n", scp->sc_onstack); + printf(" sp %08x\n", scp->sc_sp); + printf(" fp %08x\n", scp->sc_fp); + printf(" pc %08x\n", scp->sc_pc); + printf(" opcode %04x\n", opcode); + printf(" sr %08x\n", scp->sc_ps); + printf(" state %p:\n", state); + printf(" flags %d\n", state->ss_flags); + for (int i=0; i<8; i++) + printf(" d%d %08x\n", i, state->ss_frame.f_regs[i]); + for (int i=0; i<8; i++) + printf(" a%d %08x\n", i, state->ss_frame.f_regs[i+8]); + +#ifdef ENABLE_MON + char *arg[2] = {"rmon", NULL}; + mon(1, arg); #endif - } - if (memcmp(last_xpram, XPRAM, 256)) { - memcpy(last_xpram, XPRAM, 256); - SaveXPRAM(); - } + QuitEmulator(); + break; } - return NULL; } +#endif /* * Display alert */ -#if ENABLE_GTK +#ifdef ENABLE_GTK static void dl_destroyed(void) { gtk_main_quit(); @@ -530,7 +1087,7 @@ void display_alert(int title_id, int prefix_id, int button_id, const char *text) void ErrorAlert(const char *text) { -#if ENABLE_GTK +#ifdef ENABLE_GTK if (PrefsFindBool("nogui") || x_display == NULL) { printf(GetString(STR_SHELL_ERROR_PREFIX), text); return; @@ -549,7 +1106,7 @@ void ErrorAlert(const char *text) void WarningAlert(const char *text) { -#if ENABLE_GTK +#ifdef ENABLE_GTK if (PrefsFindBool("nogui") || x_display == NULL) { printf(GetString(STR_SHELL_WARNING_PREFIX), text); return; diff --git a/BasiliskII/src/Unix/posix_sem.cpp b/BasiliskII/src/Unix/posix_sem.cpp index a4279e6e..ddb3c9fb 100644 --- a/BasiliskII/src/Unix/posix_sem.cpp +++ b/BasiliskII/src/Unix/posix_sem.cpp @@ -25,10 +25,12 @@ * with mutex. Seems to be working correctly now. */ -#include #include +#include #include +#include #include + #include "semaphore.h" extern "C" { @@ -62,7 +64,6 @@ int sem_destroy(sem_t* sem) } pthread_mutex_destroy(&sem->sem_lock); sem->sem_waiting = 0; - sem->sem_lock = NULL; sem->sem_value = 0; return 0; } diff --git a/BasiliskII/src/Unix/prefs_editor_gtk.cpp b/BasiliskII/src/Unix/prefs_editor_gtk.cpp index f56cfcad..ab25e9e7 100644 --- a/BasiliskII/src/Unix/prefs_editor_gtk.cpp +++ b/BasiliskII/src/Unix/prefs_editor_gtk.cpp @@ -525,7 +525,7 @@ static GtkWidget *l_frameskip, *l_display_x, *l_display_y; static int display_type; static int dis_width, dis_height; -#if ENABLE_FBDEV_DGA +#ifdef ENABLE_FBDEV_DGA static GtkWidget *w_fbdev_name, *w_fbdevice_file; static GtkWidget *l_fbdev_name, *l_fbdevice_file; static char fbdev_name[256]; @@ -537,7 +537,7 @@ static void hide_show_graphics_widgets(void) switch (display_type) { case DISPLAY_WINDOW: gtk_widget_show(w_frameskip); gtk_widget_show(l_frameskip); -#if ENABLE_FBDEV_DGA +#ifdef ENABLE_FBDEV_DGA gtk_widget_show(w_display_x); gtk_widget_show(l_display_x); gtk_widget_show(w_display_y); gtk_widget_show(l_display_y); gtk_widget_hide(w_fbdev_name); gtk_widget_hide(l_fbdev_name); @@ -545,7 +545,7 @@ static void hide_show_graphics_widgets(void) break; case DISPLAY_SCREEN: gtk_widget_hide(w_frameskip); gtk_widget_hide(l_frameskip); -#if ENABLE_FBDEV_DGA +#ifdef ENABLE_FBDEV_DGA gtk_widget_hide(w_display_x); gtk_widget_hide(l_display_x); gtk_widget_hide(w_display_y); gtk_widget_hide(l_display_y); gtk_widget_show(w_fbdev_name); gtk_widget_show(l_fbdev_name); @@ -588,7 +588,7 @@ static void parse_graphics_prefs(void) display_type = DISPLAY_WINDOW; dis_width = 512; dis_height = 384; -#if ENABLE_FBDEV_DGA +#ifdef ENABLE_FBDEV_DGA fbdev_name[0] = 0; #endif @@ -596,7 +596,7 @@ static void parse_graphics_prefs(void) if (str) { if (sscanf(str, "win/%d/%d", &dis_width, &dis_height) == 2) display_type = DISPLAY_WINDOW; -#if ENABLE_FBDEV_DGA +#ifdef ENABLE_FBDEV_DGA else if (sscanf(str, "dga/%255s", fbdev_name) == 1) #else else if (sscanf(str, "dga/%d/%d", &dis_width, &dis_height) == 2) @@ -622,7 +622,7 @@ static void read_graphics_settings(void) sprintf(pref, "win/%d/%d", dis_width, dis_height); break; case DISPLAY_SCREEN: -#if ENABLE_FBDEV_DGA +#ifdef ENABLE_FBDEV_DGA str = gtk_entry_get_text(GTK_ENTRY(w_fbdev_name)); sprintf(pref, "dga/%s", str); #else @@ -746,7 +746,7 @@ static void create_graphics_pane(GtkWidget *top) gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 3, 4, (GtkAttachOptions)GTK_FILL, (GtkAttachOptions)0, 4, 4); w_display_y = GTK_COMBO(combo)->entry; -#if ENABLE_FBDEV_DGA +#ifdef ENABLE_FBDEV_DGA l_fbdev_name = gtk_label_new(GetString(STR_FBDEV_NAME_CTRL)); gtk_widget_show(l_fbdev_name); gtk_table_attach(GTK_TABLE(table), l_fbdev_name, 0, 1, 4, 5, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); @@ -1021,6 +1021,7 @@ static void create_memory_pane(GtkWidget *top) } make_option_menu(box, STR_MODELID_CTRL, model_options, active); +#if EMULATED_68K static const opt_desc cpu_options[] = { {STR_CPU_68020_LAB, GTK_SIGNAL_FUNC(mn_cpu_68020)}, {STR_CPU_68020_FPU_LAB, GTK_SIGNAL_FUNC(mn_cpu_68020_fpu)}, @@ -1038,6 +1039,7 @@ static void create_memory_pane(GtkWidget *top) case 4: active = 4; } make_option_menu(box, STR_CPU_CTRL, cpu_options, active); +#endif w_rom_file = make_entry(box, STR_ROM_FILE_CTRL, "rom"); diff --git a/BasiliskII/src/Unix/sysdeps.h b/BasiliskII/src/Unix/sysdeps.h index 15455ab7..b9863bab 100644 --- a/BasiliskII/src/Unix/sysdeps.h +++ b/BasiliskII/src/Unix/sysdeps.h @@ -42,7 +42,6 @@ #include #include #include -#include #ifdef HAVE_FCNTL_H # include @@ -60,18 +59,34 @@ #endif -/* Are the Mac and the host address space the same? */ +#ifdef ENABLE_NATIVE_M68K + +/* Mac and host address space are the same */ +#define REAL_ADDRESSING 1 + +/* Using 68k natively */ +#define EMULATED_68K 0 + +/* Mac ROM is not write protected */ +#define ROM_IS_WRITE_PROTECTED 0 + +#else + +/* Mac and host address space are distinct */ #define REAL_ADDRESSING 0 -/* Are we using a 68k emulator or the real thing? */ +/* Using 68k emulator */ #define EMULATED_68K 1 -/* Is the Mac ROM write protected? */ +/* Mac ROM is write protected */ #define ROM_IS_WRITE_PROTECTED 1 +#endif + /* ExtFS is supported */ #define SUPPORTS_EXTFS 1 + /* Data types */ typedef unsigned char uint8; typedef signed char int8; diff --git a/BasiliskII/src/Unix/timer_unix.cpp b/BasiliskII/src/Unix/timer_unix.cpp index 1d918f09..70b39f7e 100644 --- a/BasiliskII/src/Unix/timer_unix.cpp +++ b/BasiliskII/src/Unix/timer_unix.cpp @@ -24,6 +24,11 @@ #define DEBUG 0 #include "debug.h" +// For NetBSD with broken pthreads headers +#ifndef CLOCK_REALTIME +#define CLOCK_REALTIME 0 +#endif + /* * Return microseconds since boot (64 bit) diff --git a/BasiliskII/src/Unix/user_strings_unix.cpp b/BasiliskII/src/Unix/user_strings_unix.cpp index 2dc2e3de..9053862f 100644 --- a/BasiliskII/src/Unix/user_strings_unix.cpp +++ b/BasiliskII/src/Unix/user_strings_unix.cpp @@ -37,6 +37,13 @@ user_string_def platform_strings[] = { {STR_NO_FBDEVICE_FILE_ERR, "Cannot open frame buffer device specification file %s (%s)."}, {STR_FBDEV_NAME_ERR, "The %s frame buffer is not supported in %d bit mode."}, {STR_FBDEV_MMAP_ERR, "Cannot mmap() the frame buffer memory (%s)."}, + {STR_NO_DEV_ZERO_ERR, "Cannot open /dev/zero (%s)."}, + {STR_LOW_MEM_MMAP_ERR, "Cannot map Low Memory Globals (%s)."}, + {STR_SIGALTSTACK_ERR, "Cannot install alternate signal stack (%s)."}, + {STR_SIG_INSTALL_ERR, "Cannot install %s handler (%s)."}, + {STR_TIMER_CREATE_ERR, "Cannot create timer (%s)."}, + {STR_TIMER_SETTIME_ERR, "Cannot start timer (%s)."}, + {STR_TICK_THREAD_ERR, "Cannot create 60Hz thread (%s)."}, {STR_NO_SHEEP_NET_DRIVER_WARN, "Cannot open %s (%s). Ethernet will not be available."}, {STR_SHEEP_NET_ATTACH_WARN, "Cannot attach to Ethernet card (%s). Ethernet will not be available."}, diff --git a/BasiliskII/src/Unix/user_strings_unix.h b/BasiliskII/src/Unix/user_strings_unix.h index 80857e0a..096dd103 100644 --- a/BasiliskII/src/Unix/user_strings_unix.h +++ b/BasiliskII/src/Unix/user_strings_unix.h @@ -28,6 +28,13 @@ enum { STR_NO_FBDEVICE_FILE_ERR, STR_FBDEV_NAME_ERR, STR_FBDEV_MMAP_ERR, + STR_NO_DEV_ZERO_ERR, + STR_LOW_MEM_MMAP_ERR, + STR_SIGALTSTACK_ERR, + STR_SIG_INSTALL_ERR, + STR_TIMER_CREATE_ERR, + STR_TIMER_SETTIME_ERR, + STR_TICK_THREAD_ERR, STR_NO_SHEEP_NET_DRIVER_WARN, STR_SHEEP_NET_ATTACH_WARN, diff --git a/BasiliskII/src/Unix/video_x.cpp b/BasiliskII/src/Unix/video_x.cpp index ef4feefe..048008b8 100644 --- a/BasiliskII/src/Unix/video_x.cpp +++ b/BasiliskII/src/Unix/video_x.cpp @@ -34,9 +34,24 @@ #include #include #include -#include #include +#ifdef HAVE_PTHREADS +# include +#endif + +#ifdef ENABLE_XF86_DGA +# include +#endif + +#ifdef ENABLE_XF86_VIDMODE +# include +#endif + +#ifdef ENABLE_FBDEV_DGA +# include +#endif + #include "cpu_emulation.h" #include "main.h" #include "adb.h" @@ -48,19 +63,6 @@ #define DEBUG 1 #include "debug.h" -#if ENABLE_XF86_DGA -#include -#endif - -#if ENABLE_XF86_VIDMODE -#include -#endif - -#if ENABLE_FBDEV_DGA -#include -#endif - - // Display types enum { @@ -80,9 +82,12 @@ static int16 mouse_wheel_lines = 3; static int display_type = DISPLAY_WINDOW; // See enum above static uint8 *the_buffer; // Mac frame buffer + +#ifdef HAVE_PTHREADS static bool redraw_thread_active = false; // Flag: Redraw thread installed static volatile bool redraw_thread_cancel = false; // Flag: Cancel Redraw thread static pthread_t redraw_thread; // Redraw thread +#endif static bool has_dga = false; // Flag: Video DGA capable static bool has_vidmode = false; // Flag: VidMode extension available @@ -112,9 +117,11 @@ static int eventmask; static const int win_eventmask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | ExposureMask; static const int dga_eventmask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask; -static pthread_mutex_t palette_lock = PTHREAD_MUTEX_INITIALIZER; // Mutex to protect palette static XColor palette[256]; // Color palette for 8-bit mode static bool palette_changed = false; // Flag: Palette changed, redraw thread must set new colors +#ifdef HAVE_PTHREADS +static pthread_mutex_t palette_lock = PTHREAD_MUTEX_INITIALIZER; // Mutex to protect palette +#endif // Variables for window mode static GC the_gc; @@ -136,13 +143,15 @@ static int sm_no_boxes[] = {1,8,32,64,128,300}; static int current_dga_cmap; // Number (0 or 1) of currently installed DGA colormap static Window suspend_win; // "Suspend" window static void *fb_save = NULL; // Saved frame buffer for suspend +#ifdef HAVE_PTHREADS static pthread_mutex_t frame_buffer_lock = PTHREAD_MUTEX_INITIALIZER; // Mutex to protect frame buffer +#endif // Variables for fbdev DGA mode const char FBDEVICE_FILE_NAME[] = "/dev/fb"; static int fbdev_fd; -#if ENABLE_XF86_VIDMODE +#ifdef ENABLE_XF86_VIDMODE // Variables for XF86 VidMode support static XF86VidModeModeInfo **x_video_modes; // Array of all available modes static int num_x_video_modes; @@ -168,37 +177,52 @@ extern void SysMountFirstFloppy(void); // Set VideoMonitor according to video mode void set_video_monitor(int width, int height, int bytes_per_row, bool native_byte_order) { +#if !REAL_ADDRESSING int layout = FLAYOUT_DIRECT; switch (depth) { case 1: layout = FLAYOUT_DIRECT; - VideoMonitor.mode = VMODE_1BIT; break; case 8: layout = FLAYOUT_DIRECT; - VideoMonitor.mode = VMODE_8BIT; break; case 15: layout = FLAYOUT_HOST_555; - VideoMonitor.mode = VMODE_16BIT; break; case 16: layout = FLAYOUT_HOST_565; - VideoMonitor.mode = VMODE_16BIT; break; case 24: case 32: layout = FLAYOUT_HOST_888; + break; + } + if (native_byte_order) + MacFrameLayout = layout; + else + MacFrameLayout = FLAYOUT_DIRECT; +#endif + switch (depth) { + case 1: + VideoMonitor.mode = VMODE_1BIT; + break; + case 8: + VideoMonitor.mode = VMODE_8BIT; + break; + case 15: + VideoMonitor.mode = VMODE_16BIT; + break; + case 16: + VideoMonitor.mode = VMODE_16BIT; + break; + case 24: + case 32: VideoMonitor.mode = VMODE_32BIT; break; } VideoMonitor.x = width; VideoMonitor.y = height; VideoMonitor.bytes_per_row = bytes_per_row; - if (native_byte_order) - MacFrameLayout = layout; - else - MacFrameLayout = FLAYOUT_DIRECT; } // Trap SHM errors @@ -340,7 +364,6 @@ static bool init_window(int width, int height) #if REAL_ADDRESSING VideoMonitor.mac_frame_base = (uint32)the_buffer; - MacFrameLayout = FLAYOUT_DIRECT; #else VideoMonitor.mac_frame_base = MacFrameBaseMac; #endif @@ -350,7 +373,7 @@ static bool init_window(int width, int height) // Init fbdev DGA display static bool init_fbdev_dga(char *in_fb_name) { -#if ENABLE_FBDEV_DGA +#ifdef ENABLE_FBDEV_DGA // Find the maximum depth available int ndepths, max_depth(0); int *depths = XListDepths(x_display, screen, &ndepths); @@ -476,7 +499,6 @@ static bool init_fbdev_dga(char *in_fb_name) set_video_monitor(width, height, bytes_per_row, true); #if REAL_ADDRESSING VideoMonitor.mac_frame_base = (uint32)the_buffer; - MacFrameLayout = FLAYOUT_DIRECT; #else VideoMonitor.mac_frame_base = MacFrameBaseMac; #endif @@ -490,11 +512,11 @@ static bool init_fbdev_dga(char *in_fb_name) // Init XF86 DGA display static bool init_xf86_dga(int width, int height) { -#if ENABLE_XF86_DGA +#ifdef ENABLE_XF86_DGA // Set relative mouse mode ADBSetRelMouseMode(true); -#if ENABLE_XF86_VIDMODE +#ifdef ENABLE_XF86_VIDMODE // Switch to best mode if (has_vidmode) { int best = 0; @@ -652,7 +674,7 @@ bool VideoInit(bool classic) // Get screen depth xdepth = DefaultDepth(x_display, screen); -#if ENABLE_FBDEV_DGA +#ifdef ENABLE_FBDEV_DGA // Frame buffer name char fb_name[20]; @@ -663,7 +685,7 @@ bool VideoInit(bool classic) has_dga = false; #endif -#if ENABLE_XF86_DGA +#ifdef ENABLE_XF86_DGA // DGA available? int dga_event_base, dga_error_base; if (XF86DGAQueryExtension(x_display, &dga_event_base, &dga_error_base)) { @@ -674,7 +696,7 @@ bool VideoInit(bool classic) has_dga = false; #endif -#if ENABLE_XF86_VIDMODE +#ifdef ENABLE_XF86_VIDMODE // VidMode available? int vm_event_base, vm_error_base; has_vidmode = XF86VidModeQueryExtension(x_display, &vm_event_base, &vm_error_base); @@ -747,7 +769,7 @@ bool VideoInit(bool classic) if (mode_str) { if (sscanf(mode_str, "win/%d/%d", &width, &height) == 2) display_type = DISPLAY_WINDOW; -#if ENABLE_FBDEV_DGA +#ifdef ENABLE_FBDEV_DGA else if (has_dga && sscanf(mode_str, "dga/%19s", fb_name) == 1) { #else else if (has_dga && sscanf(mode_str, "dga/%d/%d", &width, &height) == 2) { @@ -771,7 +793,7 @@ bool VideoInit(bool classic) return false; break; case DISPLAY_DGA: -#if ENABLE_FBDEV_DGA +#ifdef ENABLE_FBDEV_DGA if (!init_fbdev_dga(fb_name)) #else if (!init_xf86_dga(width, height)) @@ -780,8 +802,10 @@ bool VideoInit(bool classic) break; } +#ifdef HAVE_PTHREADS // Lock down frame buffer pthread_mutex_lock(&frame_buffer_lock); +#endif #if !REAL_ADDRESSING // Set variables for UAE memory mapping @@ -793,12 +817,17 @@ bool VideoInit(bool classic) MacFrameLayout = FLAYOUT_NONE; #endif - // Start redraw/input thread XSync(x_display, false); + +#ifdef HAVE_PTHREADS + // Start redraw/input thread redraw_thread_active = (pthread_create(&redraw_thread, NULL, redraw_func, NULL) == 0); - if (!redraw_thread_active) + if (!redraw_thread_active) { printf("FATAL: cannot create redraw thread\n"); - return redraw_thread_active; + return false; + } +#endif + return true; } @@ -808,6 +837,7 @@ bool VideoInit(bool classic) void VideoExit(void) { +#ifdef HAVE_PTHREADS // Stop redraw thread if (redraw_thread_active) { redraw_thread_cancel = true; @@ -817,15 +847,18 @@ void VideoExit(void) pthread_join(redraw_thread, NULL); redraw_thread_active = false; } +#endif +#ifdef HAVE_PTHREADS // Unlock frame buffer pthread_mutex_unlock(&frame_buffer_lock); +#endif // Close window and server connection if (x_display != NULL) { XSync(x_display, false); -#if ENABLE_XF86_DGA +#ifdef ENABLE_XF86_DGA if (display_type == DISPLAY_DGA) { XF86DGADirectVideo(x_display, screen, 0); XUngrabPointer(x_display, CurrentTime); @@ -833,12 +866,12 @@ void VideoExit(void) } #endif -#if ENABLE_XF86_VIDMODE +#ifdef ENABLE_XF86_VIDMODE if (has_vidmode && display_type == DISPLAY_DGA) XF86VidModeSwitchToMode(x_display, screen, x_video_modes[0]); #endif -#if ENABLE_FBDEV_DGA +#ifdef ENABLE_FBDEV_DGA if (display_type == DISPLAY_DGA) { XUngrabPointer(x_display, CurrentTime); XUngrabKeyboard(x_display, CurrentTime); @@ -888,10 +921,12 @@ void VideoInterrupt(void) if (emerg_quit) QuitEmulator(); +#ifdef HAVE_PTHREADS // Temporarily give up frame buffer lock (this is the point where // we are suspended when the user presses Ctrl-Tab) pthread_mutex_unlock(&frame_buffer_lock); pthread_mutex_lock(&frame_buffer_lock); +#endif } @@ -901,7 +936,9 @@ void VideoInterrupt(void) void video_set_palette(uint8 *pal) { +#ifdef HAVE_PTHREDS pthread_mutex_lock(&palette_lock); +#endif // Convert colors to XColor array for (int i=0; i<256; i++) { @@ -915,7 +952,9 @@ void video_set_palette(uint8 *pal) // Tell redraw thread to change palette palette_changed = true; +#ifdef HAVE_PTHREADS pthread_mutex_unlock(&palette_lock); +#endif } @@ -923,7 +962,7 @@ void video_set_palette(uint8 *pal) * Suspend/resume emulator */ -#if ENABLE_XF86_DGA || ENABLE_FBDEV_DGA +#if defined(ENABLE_XF86_DGA) || defined(ENABLE_FBDEV_DGA) static void suspend_emul(void) { if (display_type == DISPLAY_DGA) { @@ -931,8 +970,10 @@ static void suspend_emul(void) ADBKeyUp(0x36); ctrl_down = false; +#ifdef HAVE_PTHREADS // Lock frame buffer (this will stop the MacOS thread) pthread_mutex_lock(&frame_buffer_lock); +#endif // Save frame buffer fb_save = malloc(VideoMonitor.y * VideoMonitor.bytes_per_row); @@ -940,7 +981,7 @@ static void suspend_emul(void) memcpy(fb_save, the_buffer, VideoMonitor.y * VideoMonitor.bytes_per_row); // Close full screen display -#if ENABLE_XF86_DGA +#ifdef ENABLE_XF86_DGA XF86DGADirectVideo(x_display, screen, 0); #endif XUngrabPointer(x_display, CurrentTime); @@ -981,7 +1022,7 @@ static void resume_emul(void) XSync(x_display, false); XGrabKeyboard(x_display, rootwin, 1, GrabModeAsync, GrabModeAsync, CurrentTime); XGrabPointer(x_display, rootwin, 1, PointerMotionMask | ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime); -#if ENABLE_XF86_DGA +#ifdef ENABLE_XF86_DGA XF86DGADirectVideo(x_display, screen, XF86DGADirectGraphics | XF86DGADirectKeyb | XF86DGADirectMouse); XF86DGASetViewPort(x_display, screen, 0, 0); #endif @@ -994,14 +1035,16 @@ static void resume_emul(void) fb_save = NULL; } +#ifdef ENABLE_XF86_DGA if (depth == 8) -#if ENABLE_XF86_DGA XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]); #endif +#ifdef HAVE_PTHREADS // Unlock frame buffer (and continue MacOS thread) pthread_mutex_unlock(&frame_buffer_lock); emul_suspended = false; +#endif } #endif @@ -1063,7 +1106,7 @@ static int kc_decode(KeySym ks) case XK_period: case XK_greater: return 0x2f; case XK_slash: case XK_question: return 0x2c; -#if ENABLE_XF86_DGA || ENABLE_FBDEV_DGA +#if defined(ENABLE_XF86_DGA) || defined(ENABLE_FBDEV_DGA) case XK_Tab: if (ctrl_down) {suspend_emul(); return -1;} else return 0x30; #else case XK_Tab: return 0x30; @@ -1242,7 +1285,7 @@ static void handle_events(void) if (code == 0x36) ctrl_down = true; } else { -#if ENABLE_XF86_DGA || ENABLE_FBDEV_DGA +#if defined(ENABLE_XF86_DGA) || defined(ENABLE_FBDEV_DGA) if (code == 0x31) resume_emul(); // Space wakes us up #endif @@ -1378,72 +1421,69 @@ static void update_display(int ticker) * Thread for screen refresh, input handling etc. */ +void VideoRefresh(void) +{ +#if defined(ENABLE_XF86_DGA) || defined(ENABLE_FBDEV_DGA) + // Quit DGA mode if requested + if (quit_full_screen) { + quit_full_screen = false; + if (display_type == DISPLAY_DGA) { +#ifdef ENABLE_XF86_DGA + XF86DGADirectVideo(x_display, screen, 0); +#endif + XUngrabPointer(x_display, CurrentTime); + XUngrabKeyboard(x_display, CurrentTime); + XUnmapWindow(x_display, the_win); + XSync(x_display, false); + } + } +#endif + + // Handle X events + handle_events(); + + // Handle palette changes +#ifdef HAVE_PTHREADS + pthread_mutex_lock(&palette_lock); +#endif + if (palette_changed) { + palette_changed = false; + if (depth == 8) { + XStoreColors(x_display, cmap[0], palette, 256); + XStoreColors(x_display, cmap[1], palette, 256); + +#ifdef ENABLE_XF86_DGA + if (display_type == DISPLAY_DGA) { + current_dga_cmap ^= 1; + XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]); + } +#endif + } + } +#ifdef HAVE_PTHREADS + pthread_mutex_unlock(&palette_lock); +#endif + + // In window mode, update display + static int tick_counter = 0; + if (display_type == DISPLAY_WINDOW) { + tick_counter++; + update_display(tick_counter); + } +} + +#ifdef HAVE_PTHREADS static void *redraw_func(void *arg) { - int tick_counter = 0; - while (!redraw_thread_cancel) { - - // Wait #ifdef HAVE_NANOSLEEP struct timespec req = {0, 16666667}; nanosleep(&req, NULL); #else usleep(16667); #endif - -#if ENABLE_XF86_DGA - // Quit DGA mode if requested - if (quit_full_screen) { - quit_full_screen = false; - if (display_type == DISPLAY_DGA) { - XF86DGADirectVideo(x_display, screen, 0); - XUngrabPointer(x_display, CurrentTime); - XUngrabKeyboard(x_display, CurrentTime); - XUnmapWindow(x_display, the_win); - XSync(x_display, false); - } - } -#endif - -#if ENABLE_FBDEV_DGA - // Quit DGA mode if requested - if (quit_full_screen) { - quit_full_screen = false; - if (display_type == DISPLAY_DGA) { - XUngrabPointer(x_display, CurrentTime); - XUngrabKeyboard(x_display, CurrentTime); - XUnmapWindow(x_display, the_win); - XSync(x_display, false); - } - } -#endif - // Handle X events - handle_events(); - - // Handle palette changes - pthread_mutex_lock(&palette_lock); - if (palette_changed) { - palette_changed = false; - if (depth == 8) { - XStoreColors(x_display, cmap[0], palette, 256); - XStoreColors(x_display, cmap[1], palette, 256); - -#if ENABLE_XF86_DGA - if (display_type == DISPLAY_DGA) { - current_dga_cmap ^= 1; - XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]); - } -#endif - } - } - pthread_mutex_unlock(&palette_lock); - - // In window mode, update display - if (display_type == DISPLAY_WINDOW) { - tick_counter++; - update_display(tick_counter); - } + VideoRefresh(); } return NULL; } +#endif