diff --git a/BasiliskII/ChangeLog b/BasiliskII/ChangeLog index 2c3c7904..ece429c1 100644 --- a/BasiliskII/ChangeLog +++ b/BasiliskII/ChangeLog @@ -6,6 +6,7 @@ V0.8 (snapshot) - [Jürgen Lachmann] - AmigaOS/Unix/extfs_*.cpp: .finf helper file now stores complete FInfo/FXInfo, replaced get/set_finder_*() functions by get/set_finfo() + - Unix: improved timing of periodic threads - include/macos_util.h: defines FOURCC() macro to make MacOS-like four-character-codes, replaced most instances of multi-character constants in the sources by this macro to avoid compiler warnings diff --git a/BasiliskII/src/Unix/aclocal.m4 b/BasiliskII/src/Unix/aclocal.m4 index 6aeeeabb..3243d88f 100644 --- a/BasiliskII/src/Unix/aclocal.m4 +++ b/BasiliskII/src/Unix/aclocal.m4 @@ -1,7 +1,19 @@ +dnl aclocal.m4 generated automatically by aclocal 1.4 + +dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without +dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A +dnl PARTICULAR PURPOSE. + # Configure paths for GTK+ # Owen Taylor 97-11-3 -dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]]) dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS dnl AC_DEFUN(AM_PATH_GTK, @@ -15,6 +27,15 @@ AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program], , enable_gtktest=yes) + for module in . $4 + do + case "$module" in + gthread) + gtk_config_args="$gtk_config_args gthread" + ;; + esac + done + if test x$gtk_config_exec_prefix != x ; then gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix" if test x${GTK_CONFIG+set} != xset ; then @@ -47,7 +68,7 @@ AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $GTK_CFLAGS" - LIBS="$LIBS $GTK_LIBS" + LIBS="$GTK_LIBS $LIBS" dnl dnl Now check if the installed GTK is sufficiently new. (Also sanity dnl checks the results of gtk-config to some extent @@ -56,15 +77,19 @@ dnl AC_TRY_RUN([ #include #include +#include int main () { int major, minor, micro; + char *tmp_version; system ("touch conf.gtktest"); - if (sscanf("$min_gtk_version", "%d.%d.%d", &major, &minor, µ) != 3) { + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_gtk_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_gtk_version"); exit(1); } @@ -85,6 +110,17 @@ main () printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n"); printf("*** before re-running configure\n"); } +#if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION) + else if ((gtk_major_version != GTK_MAJOR_VERSION) || + (gtk_minor_version != GTK_MINOR_VERSION) || + (gtk_micro_version != GTK_MICRO_VERSION)) + { + printf("*** GTK+ header files (version %d.%d.%d) do not match\n", + GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); + printf("*** library (version %d.%d.%d)\n", + gtk_major_version, gtk_minor_version, gtk_micro_version); + } +#endif /* defined (GTK_MAJOR_VERSION) ... */ else { if ((gtk_major_version > major) || @@ -169,7 +205,6 @@ main () rm -f conf.gtktest ]) - # Configure paths for ESD # Manish Singh 98-9-30 # stolen back from Frank Belew @@ -334,3 +369,4 @@ int main () AC_SUBST(ESD_LIBS) rm -f conf.esdtest ]) + diff --git a/BasiliskII/src/Unix/config.h.in b/BasiliskII/src/Unix/config.h.in index 350f1ca4..3c24d273 100644 --- a/BasiliskII/src/Unix/config.h.in +++ b/BasiliskII/src/Unix/config.h.in @@ -73,9 +73,6 @@ /* Define if you have the clock_gettime function. */ #undef HAVE_CLOCK_GETTIME -/* Define if you have the nanosleep function. */ -#undef HAVE_NANOSLEEP - /* Define if you have the pthread_cancel function. */ #undef HAVE_PTHREAD_CANCEL diff --git a/BasiliskII/src/Unix/configure b/BasiliskII/src/Unix/configure index c468461f..545c7a0e 100755 --- a/BasiliskII/src/Unix/configure +++ b/BasiliskII/src/Unix/configure @@ -2681,6 +2681,15 @@ else fi + for module in . + do + case "$module" in + gthread) + gtk_config_args="$gtk_config_args gthread" + ;; + esac + done + if test x$gtk_config_exec_prefix != x ; then gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix" if test x${GTK_CONFIG+set} != xset ; then @@ -2697,7 +2706,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:2701: checking for $ac_word" >&5 +echo "configure:2710: 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 @@ -2732,7 +2741,7 @@ fi min_gtk_version=1.2.0 echo $ac_n "checking for GTK - version >= $min_gtk_version""... $ac_c" 1>&6 -echo "configure:2736: checking for GTK - version >= $min_gtk_version" >&5 +echo "configure:2745: checking for GTK - version >= $min_gtk_version" >&5 no_gtk="" if test "$GTK_CONFIG" = "no" ; then no_gtk=yes @@ -2749,26 +2758,30 @@ echo "configure:2736: checking for GTK - version >= $min_gtk_version" >&5 ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $GTK_CFLAGS" - LIBS="$LIBS $GTK_LIBS" + LIBS="$GTK_LIBS $LIBS" rm -f conf.gtktest if test "$cross_compiling" = yes; then echo $ac_n "cross compiling; assumed OK... $ac_c" else cat > conftest.$ac_ext < #include +#include int main () { int major, minor, micro; + char *tmp_version; system ("touch conf.gtktest"); - if (sscanf("$min_gtk_version", "%d.%d.%d", &major, &minor, µ) != 3) { + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_gtk_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_gtk_version"); exit(1); } @@ -2789,6 +2802,17 @@ main () printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n"); printf("*** before re-running configure\n"); } +#if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION) + else if ((gtk_major_version != GTK_MAJOR_VERSION) || + (gtk_minor_version != GTK_MINOR_VERSION) || + (gtk_micro_version != GTK_MICRO_VERSION)) + { + printf("*** GTK+ header files (version %d.%d.%d) do not match\n", + GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); + printf("*** library (version %d.%d.%d)\n", + gtk_major_version, gtk_minor_version, gtk_micro_version); + } +#endif /* defined (GTK_MAJOR_VERSION) ... */ else { if ((gtk_major_version > major) || @@ -2818,7 +2842,7 @@ main () } EOF -if { (eval echo configure:2822: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2846: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -2861,7 +2885,7 @@ EOF CFLAGS="$CFLAGS $GTK_CFLAGS" LIBS="$LIBS $GTK_LIBS" cat > conftest.$ac_ext < @@ -2871,7 +2895,7 @@ int main() { return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ; return 0; } EOF -if { (eval echo configure:2875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2899: \"$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" @@ -2956,7 +2980,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:2960: checking for $ac_word" >&5 +echo "configure:2984: 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 @@ -2991,7 +3015,7 @@ fi min_esd_version=0.2.8 echo $ac_n "checking for ESD - version >= $min_esd_version""... $ac_c" 1>&6 -echo "configure:2995: checking for ESD - version >= $min_esd_version" >&5 +echo "configure:3019: checking for ESD - version >= $min_esd_version" >&5 no_esd="" if test "$ESD_CONFIG" = "no" ; then no_esd=yes @@ -3015,7 +3039,7 @@ echo "configure:2995: checking for ESD - version >= $min_esd_version" >&5 echo $ac_n "cross compiling; assumed OK... $ac_c" else cat > conftest.$ac_ext < @@ -3073,7 +3097,7 @@ int main () EOF -if { (eval echo configure:3077: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3101: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -3115,7 +3139,7 @@ EOF CFLAGS="$CFLAGS $ESD_CFLAGS" LIBS="$LIBS $ESD_LIBS" cat > conftest.$ac_ext < @@ -3125,7 +3149,7 @@ int main() { return 0; ; return 0; } EOF -if { (eval echo configure:3129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3153: \"$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" @@ -3164,12 +3188,12 @@ rm -f conftest* fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:3168: checking for ANSI C header files" >&5 +echo "configure:3192: 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 @@ -3177,7 +3201,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3181: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3205: \"$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* @@ -3194,7 +3218,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 @@ -3212,7 +3236,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 @@ -3233,7 +3257,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -3244,7 +3268,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:3248: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3272: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -3271,17 +3295,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:3275: checking for $ac_hdr" >&5 +echo "configure:3299: 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:3285: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3309: \"$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* @@ -3309,14 +3333,14 @@ done echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6 -echo "configure:3313: checking whether byte ordering is bigendian" >&5 +echo "configure:3337: 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 @@ -3327,11 +3351,11 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:3331: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3355: \"$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 @@ -3342,7 +3366,7 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:3346: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3370: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_bigendian=yes else @@ -3362,7 +3386,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:3403: \"$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 @@ -3399,12 +3423,12 @@ EOF fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:3403: checking for working const" >&5 +echo "configure:3427: 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:3481: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -3474,21 +3498,21 @@ EOF fi echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:3478: checking for inline" >&5 +echo "configure:3502: 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:3516: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -3514,7 +3538,7 @@ EOF esac echo $ac_n "checking size of short""... $ac_c" 1>&6 -echo "configure:3518: checking size of short" >&5 +echo "configure:3542: 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 @@ -3522,7 +3546,7 @@ else ac_cv_sizeof_short=2 else cat > conftest.$ac_ext < main() @@ -3533,7 +3557,7 @@ main() exit(0); } EOF -if { (eval echo configure:3537: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3561: \"$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 @@ -3553,7 +3577,7 @@ EOF echo $ac_n "checking size of int""... $ac_c" 1>&6 -echo "configure:3557: checking size of int" >&5 +echo "configure:3581: 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 @@ -3561,7 +3585,7 @@ else ac_cv_sizeof_int=4 else cat > conftest.$ac_ext < main() @@ -3572,7 +3596,7 @@ main() exit(0); } EOF -if { (eval echo configure:3576: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3600: \"$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 @@ -3592,7 +3616,7 @@ EOF echo $ac_n "checking size of long""... $ac_c" 1>&6 -echo "configure:3596: checking size of long" >&5 +echo "configure:3620: 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 @@ -3600,7 +3624,7 @@ else ac_cv_sizeof_long=4 else cat > conftest.$ac_ext < main() @@ -3611,7 +3635,7 @@ main() exit(0); } EOF -if { (eval echo configure:3615: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3639: \"$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 @@ -3631,7 +3655,7 @@ EOF echo $ac_n "checking size of long long""... $ac_c" 1>&6 -echo "configure:3635: checking size of long long" >&5 +echo "configure:3659: 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 @@ -3639,7 +3663,7 @@ else ac_cv_sizeof_long_long=8 else cat > conftest.$ac_ext < main() @@ -3650,7 +3674,7 @@ main() exit(0); } EOF -if { (eval echo configure:3654: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3678: \"$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 @@ -3670,12 +3694,12 @@ EOF echo $ac_n "checking for off_t""... $ac_c" 1>&6 -echo "configure:3674: checking for off_t" >&5 +echo "configure:3698: 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 @@ -3703,12 +3727,12 @@ EOF fi echo $ac_n "checking for loff_t""... $ac_c" 1>&6 -echo "configure:3707: checking for loff_t" >&5 +echo "configure:3731: 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 @@ -3736,12 +3760,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:3740: checking for size_t" >&5 +echo "configure:3764: 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 @@ -3769,12 +3793,12 @@ EOF fi echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:3773: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:3797: 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 @@ -3783,7 +3807,7 @@ int main() { struct tm *tp; ; return 0; } EOF -if { (eval echo configure:3787: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3811: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -3804,12 +3828,12 @@ EOF fi echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 -echo "configure:3808: checking whether struct tm is in sys/time.h or time.h" >&5 +echo "configure:3832: 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 @@ -3817,7 +3841,7 @@ int main() { struct tm *tp; tp->tm_sec; ; return 0; } EOF -if { (eval echo configure:3821: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3845: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm=time.h else @@ -3841,12 +3865,12 @@ fi for ac_func in strdup cfmakeraw do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3845: checking for $ac_func" >&5 +echo "configure:3869: 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:3897: \"$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 @@ -3893,15 +3917,15 @@ else fi done -for ac_func in nanosleep clock_gettime timer_create +for ac_func in clock_gettime timer_create do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3900: checking for $ac_func" >&5 +echo "configure:3924: 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:3952: \"$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 @@ -3966,7 +3990,7 @@ if MACHINE=`uname -s 2>/dev/null`; then 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:3970: checking for cam_open_btl in -lcam" >&5 +echo "configure:3994: 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 @@ -3974,7 +3998,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:4013: \"$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 @@ -4011,17 +4035,17 @@ fi 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:4015: checking for /sys/cam/cam.h" >&5 +echo "configure:4039: 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:4025: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4049: \"$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* @@ -4056,7 +4080,7 @@ fi FreeBSD*) DEFINES="$DEFINES -DBSD_COMP" echo $ac_n "checking for scsi_open in -lscsi""... $ac_c" 1>&6 -echo "configure:4060: checking for scsi_open in -lscsi" >&5 +echo "configure:4084: 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 @@ -4064,7 +4088,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:4103: \"$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 @@ -4101,17 +4125,17 @@ fi 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:4105: checking for scsi.h sys/scsiio.h" >&5 +echo "configure:4129: 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:4115: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4139: \"$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* @@ -4164,7 +4188,7 @@ SYSSRCS="$SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRA HAVE_GAS=no echo $ac_n "checking for GAS .p2align feature""... $ac_c" 1>&6 -echo "configure:4168: checking for GAS .p2align feature" >&5 +echo "configure:4192: checking for GAS .p2align feature" >&5 cat >conftest.S << EOF .text .p2align 5 @@ -4174,9 +4198,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:4178: checking for GCC 2.7 or higher" >&5 +echo "configure:4202: checking for GCC 2.7 or higher" >&5 cat > conftest.$ac_ext < 1 || __GNUC_MINOR__ - 1 > 5 yes @@ -4215,7 +4239,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:4219: checking SPARC CPU architecture" >&5 +echo "configure:4243: checking SPARC CPU architecture" >&5 SPARC_TYPE=`Solaris/which_sparc` echo "$ac_t""$SPARC_TYPE" 1>&6 case "$SPARC_TYPE" in diff --git a/BasiliskII/src/Unix/configure.in b/BasiliskII/src/Unix/configure.in index f6017394..ee5a43c7 100644 --- a/BasiliskII/src/Unix/configure.in +++ b/BasiliskII/src/Unix/configure.in @@ -180,7 +180,7 @@ AC_STRUCT_TM dnl Checks for library functions. AC_CHECK_FUNCS(strdup cfmakeraw) -AC_CHECK_FUNCS(nanosleep clock_gettime timer_create) +AC_CHECK_FUNCS(clock_gettime timer_create) dnl Select system-dependant source files. SERIALSRC=serial_unix.cpp diff --git a/BasiliskII/src/Unix/main_unix.cpp b/BasiliskII/src/Unix/main_unix.cpp index 06d59178..89a96c6a 100644 --- a/BasiliskII/src/Unix/main_unix.cpp +++ b/BasiliskII/src/Unix/main_unix.cpp @@ -687,14 +687,8 @@ static void xpram_watchdog(void) 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 - } + for (int i=0; i<60 && !xpram_thread_cancel; i++) + Delay_usec(1000000); xpram_watchdog(); } return NULL; @@ -746,24 +740,77 @@ static void one_tick(...) #ifdef HAVE_PTHREADS static void *tick_func(void *arg) { + uint64 next = GetTicks_usec(); while (!tick_thread_cancel) { - - // Wait -#ifdef HAVE_NANOSLEEP - struct timespec req = {0, 16625000}; - nanosleep(&req, NULL); -#else - usleep(16625); -#endif - - // Action one_tick(); + next += 16625; + int64 delay = next - GetTicks_usec(); + if (delay > 0) + Delay_usec(delay); + else if (delay < -16625) + next = GetTicks_usec(); } return NULL; } #endif +/* + * Get current value of microsecond timer + */ + +uint64 GetTicks_usec(void) +{ +#ifdef HAVE_CLOCK_GETTIME + struct timespec t; + clock_gettime(CLOCK_REALTIME, &t); + return (uint64)t.tv_sec * 1000000 + t.tv_nsec / 1000; +#else + struct timeval t; + gettimeofday(&t, NULL); + return (uint64)t.tv_sec * 1000000 + t.tv_usec; +#endif +} + + +/* + * Delay by specified number of microseconds (<1 second) + * (adapted from SDL_Delay() source) + */ + +void Delay_usec(uint32 usec) +{ + int was_error; +#ifndef __linux__ // Non-Linux implementations need to calculate time left + uint64 then, now, elapsed; +#endif + struct timeval tv; + + // Set the timeout interval - Linux only needs to do this once +#ifdef __linux__ + tv.tv_sec = 0; + tv.tv_usec = usec; +#else + then = GetTicks_usec(); +#endif + do { + errno = 0; +#ifndef __linux__ + /* Calculate the time interval left (in case of interrupt) */ + now = GetTicks_usec(); + elapsed = now - then; + then = now; + if (elapsed >= usec) + break; + usec -= elapsed; + tv.tv_sec = 0; + tv.tv_usec = usec; +#endif + was_error = select(0, NULL, NULL, NULL, &tv); + } while (was_error && (errno == EINTR)); +} + + #if !EMULATED_68K /* * Virtual 68k interrupt handler diff --git a/BasiliskII/src/Unix/sysdeps.h b/BasiliskII/src/Unix/sysdeps.h index b9863bab..9bea1c85 100644 --- a/BasiliskII/src/Unix/sysdeps.h +++ b/BasiliskII/src/Unix/sysdeps.h @@ -148,6 +148,10 @@ typedef uae_u32 uaecptr; # define CPU_CAN_ACCESS_UNALIGNED #endif +/* Timing functions */ +extern uint64 GetTicks_usec(void); +extern void Delay_usec(uint32 usec); + /* UAE CPU defines */ #ifdef WORDS_BIGENDIAN diff --git a/BasiliskII/src/Unix/video_x.cpp b/BasiliskII/src/Unix/video_x.cpp index 6fe78d99..c922bb09 100644 --- a/BasiliskII/src/Unix/video_x.cpp +++ b/BasiliskII/src/Unix/video_x.cpp @@ -1458,8 +1458,7 @@ static void update_display_static(void) x1 = i << 3; break; } - p++; - p2++; + p++; p2++; } } x2 = x1; @@ -1469,8 +1468,7 @@ static void update_display_static(void) p += bytes_per_row; p2 += bytes_per_row; for (i=(VideoMonitor.x>>3); i>(x2>>3); i--) { - p--; - p2--; + p--; p2--; if (*p != *p2) { x2 = i << 3; break; @@ -1492,13 +1490,12 @@ static void update_display_static(void) for (j=y1; j<=y2; j++) { p = &the_buffer[j * bytes_per_row]; p2 = &the_buffer_copy[j * bytes_per_row]; - for (i=0; ix2; i--) { - p -= bytes_per_pixel; - p2 -= bytes_per_pixel; - if (memcmp(p, p2, bytes_per_pixel)) { - x2 = i; + for (i=VideoMonitor.x*bytes_per_pixel; i>x2*bytes_per_pixel; i--) { + p--; + p2--; + if (*p != *p2) { + x2 = i / bytes_per_pixel; break; } } @@ -1601,15 +1598,21 @@ void VideoRefresh(void) #ifdef HAVE_PTHREADS static void *redraw_func(void *arg) { +uint64 start = GetTicks_usec(); +int64 ticks = 0; + uint64 next = GetTicks_usec(); while (!redraw_thread_cancel) { -#ifdef HAVE_NANOSLEEP - struct timespec req = {0, 16666667}; - nanosleep(&req, NULL); -#else - usleep(16667); -#endif VideoRefresh(); + next += 16667; + int64 delay = next - GetTicks_usec(); + if (delay > 0) + Delay_usec(delay); + else if (delay < -16667) + next = GetTicks_usec(); +ticks++; } +uint64 end = GetTicks_usec(); +printf("%Ld ticks in %Ld usec = %Ld ticks/sec\n", ticks, end - start, (end - start) / ticks); return NULL; } #endif