diff --git a/m4/docs.m4 b/m4/docs.m4 index b424ab66..55d78eb8 100644 --- a/m4/docs.m4 +++ b/m4/docs.m4 @@ -12,7 +12,7 @@ AC_DEFUN([AC_FLDIGI_DOCS], [ asciidoc_min=8.2.0 if test "x$ASCIIDOC" != "x"; then AC_MSG_CHECKING([for asciidoc >= $asciidoc_min]) - asciidoc_ver=$($ASCIIDOC --version | sed -n '1 { s/.* //; p }') + asciidoc_ver=$($ASCIIDOC --version | sed -n '1 s/.* //; p') AX_COMPARE_VERSION([$asciidoc_ver], [ge], [$asciidoc_min], [AC_MSG_RESULT([yes ($asciidoc_ver)])], [AC_MSG_RESULT([no ($asciidoc_ver)]); ASCIIDOC=""]) diff --git a/m4/oss.m4 b/m4/oss.m4 index 0c0f8a60..98f80d9c 100644 --- a/m4/oss.m4 +++ b/m4/oss.m4 @@ -19,7 +19,8 @@ AC_DEFUN([AC_FLDIGI_OSS], [ AC_DEFINE(USE_OSS, 0, [Defined if we are using OSS]) else AC_CHECK_HEADER( [sys/soundcard.h], [ac_cv_oss=yes], - [AC_CHECK_HEADER([machine/soundcard.h], [ac_cv_oss=yes], [])] ) + [AC_CHECK_HEADER([machine/soundcard.h], [ac_cv_oss=yes], + [AC_CHECK_HEADER([soundcard.h], [ac_cv_oss=yes], [])])]) if test "x$ac_cv_want_oss" = "xcheck"; then if test "x$ac_cv_oss" = "xyes"; then AC_DEFINE(USE_OSS, 1, [Defined if we are using OSS]) diff --git a/src/dialogs/fl_digi.cxx b/src/dialogs/fl_digi.cxx index c73a6a7a..015aac25 100644 --- a/src/dialogs/fl_digi.cxx +++ b/src/dialogs/fl_digi.cxx @@ -2091,7 +2091,10 @@ void ztimer(void* first_call) Fl::repeat_timeout(1.0, ztimer); struct tm tm; - gmtime_r(&tv.tv_sec, &tm); + time_t t_temp; + + t_temp=(time_t)tv.tv_sec; + gmtime_r(&t_temp, &tm); if (!strftime(ztbuf, sizeof(ztbuf), "%Y%m%d %H%M%S", &tm)) memset(ztbuf, 0, sizeof(ztbuf)); else diff --git a/src/include/configuration.h b/src/include/configuration.h index 09824a99..aaf98166 100644 --- a/src/include/configuration.h +++ b/src/include/configuration.h @@ -40,6 +40,14 @@ # define DEFAULT_PTTDEV "/dev/ttyd0" # define DEFAULT_CWFSKPORT "/dev/ttyd1" # define DEFAULT_HAMRIGDEVICE "/dev/ttyd0" +#elif defined(__NetBSD__) +# define DEFAULT_PTTDEV "/dev/tty00" +# define DEFAULT_CWFSKPORT "/dev/tty01" +# define DEFAULT_HAMRIGDEVICE "/dev/tty00" +#elif defined(__OpenBSD__) +# define DEFAULT_PTTDEV "/dev/tty00" +# define DEFAULT_CWFSKPORT "/dev/tty01" +# define DEFAULT_HAMRIGDEVICE "/dev/tty00" #elif defined(__WOE32__) # define DEFAULT_PTTDEV "COM1" # define DEFAULT_CWFSKPORT "COM2" diff --git a/src/include/mixer.h b/src/include/mixer.h index e65767c2..aa48f8f0 100644 --- a/src/include/mixer.h +++ b/src/include/mixer.h @@ -32,7 +32,11 @@ #include #if USE_OSS +# if defined(__OpenBSD__) +# include +# else # include +# endif #endif class MixerException { diff --git a/src/include/socket.h b/src/include/socket.h index 58f61919..ccb0e94b 100644 --- a/src/include/socket.h +++ b/src/include/socket.h @@ -29,6 +29,9 @@ #ifndef __MINGW32__ # include # include +# if defined(__OpenBSD__) && defined(nitems) +# undef nitems +# endif # include #else # include diff --git a/src/misc/configuration.cxx b/src/misc/configuration.cxx index fc7c3c62..ba3340c5 100644 --- a/src/misc/configuration.cxx +++ b/src/misc/configuration.cxx @@ -970,6 +970,8 @@ out: "/dev/usb/ttyUSB%u" #elif defined(__FreeBSD__) "/dev/ttyd%u" +#elif defined(__OpenBSD__) || defined(__NetBSD__) + "/dev/tty%2.2u" #elif defined(__CYGWIN__) "/dev/ttyS%u" #elif defined(__MINGW32__) @@ -984,6 +986,8 @@ out: # define TTY_MAX 255 #elif defined(__APPLE__) glob_t gbuf; +#elif defined(__OpenBSD__) || defined(__NetBSD__) +# define TTY_MAX 4 #else # define TTY_MAX 8 #endif diff --git a/src/misc/macroedit.cxx b/src/misc/macroedit.cxx index 04f9d94a..66e7f3cb 100644 --- a/src/misc/macroedit.cxx +++ b/src/misc/macroedit.cxx @@ -224,7 +224,12 @@ void loadBrowser(Fl_Widget *widget) { } w->add(LINE_SEP); struct stat st; + +# if defined(__OpenBSD__) + for (int i = 0; i < gbuf.gl_pathc; i++) { +# else for (size_t i = 0; i < gbuf.gl_pathc; i++) { +# endif if (!(stat(gbuf.gl_pathv[i], &st) == 0 && S_ISREG(st.st_mode) && (st.st_mode & S_IXUSR))) continue; diff --git a/src/misc/socket.cxx b/src/misc/socket.cxx index bfd8a2d2..dcb50eed 100644 --- a/src/misc/socket.cxx +++ b/src/misc/socket.cxx @@ -27,6 +27,9 @@ #ifndef __MINGW32__ # include # include +# if defined(__OpenBSD__) && defined(nitems) +# undef nitems +# endif # include # include # include diff --git a/src/rigcontrol/rigMEM.cxx b/src/rigcontrol/rigMEM.cxx index 6c21d540..3555f369 100644 --- a/src/rigcontrol/rigMEM.cxx +++ b/src/rigcontrol/rigMEM.cxx @@ -22,6 +22,10 @@ #include +#if defined(__OpenBSD__) +# include +#endif + #if !defined(__WOE32__) && !defined(__APPLE__) # include # include diff --git a/src/soundcard/mixer.cxx b/src/soundcard/mixer.cxx index fbdcff15..66e52b1c 100644 --- a/src/soundcard/mixer.cxx +++ b/src/soundcard/mixer.cxx @@ -36,8 +36,12 @@ #include #include #if USE_OSS -# include +# include +# if defined(__OpenBSD__) +# include +# else # include +# endif #endif #include diff --git a/src/soundcard/sound.cxx b/src/soundcard/sound.cxx index e5d6abc8..f83f314e 100644 --- a/src/soundcard/sound.cxx +++ b/src/soundcard/sound.cxx @@ -45,8 +45,12 @@ #include #if USE_OSS -# include +# include +# if defined(__OpenBSD__) +# include +# else # include +# endif #endif #include diff --git a/src/wefax/wefax.cxx b/src/wefax/wefax.cxx index 08284661..46efac24 100644 --- a/src/wefax/wefax.cxx +++ b/src/wefax/wefax.cxx @@ -881,7 +881,7 @@ public: /// Called when loading a file from the GUI, or indirectly from XML-RPC. bool transmit_lock_acquire(const std::string & filnam, double delay = wefax::max_delay ) { - LOG_INFO("Sending %s delay=%f tid=%d", filnam.c_str(), delay, GET_THREAD_ID() ); + LOG_INFO("Sending %s delay=%f tid=%d", filnam.c_str(), delay, (int)GET_THREAD_ID() ); guard_lock g( m_sync_tx_fil.mtxp() ); LOG_INFO("Locked"); if ( ! m_tx_fil.empty() ) @@ -896,7 +896,7 @@ public: /// Allows to send another file. Called by XML-RPC and the GUI. void transmit_lock_release( const std::string & err_msg ) { - LOG_INFO("err_msg=%s tid=%d", err_msg.c_str(), GET_THREAD_ID() ); + LOG_INFO("err_msg=%s tid=%d", err_msg.c_str(), (int)GET_THREAD_ID() ); guard_lock g( m_sync_tx_msg.mtxp() ); LOG_INFO("%s %s", m_tx_fil.c_str(), err_msg.c_str() ); if( m_tx_fil.empty() ) @@ -1031,7 +1031,7 @@ public: } } - LOG_INFO("Shift: i=%d hist=%d", best_shift_idx, biggest_shift ); + LOG_INFO("Shift: i=%d hist=%d", (int)best_shift_idx, (int)biggest_shift ); } return best_shift_idx ; } @@ -2491,19 +2491,9 @@ wefax::wefax(trx_mode wefax_mode) : modem() // receive processing //===================================================================== -#ifdef __linux__ - -#include /// This must return the current time in seconds with high precision. -static double current_time(void) -{ - struct timeb tmp_timb ; - ftime( &tmp_timb ); - return (double)tmp_timb.time + tmp_timb.millitm / 1000.0 ; -} - -#else +#if defined(__WIN32__) || defined(__APPLE__) #include /// This is much less accurate. static double current_time(void) @@ -2512,8 +2502,50 @@ static double current_time(void) return clks * 1.0 / CLOCKS_PER_SEC; } -#endif +#else +#if defined(HAVE_CLOCK_GETTIME) +#include + +static double current_time(void) +{ +// DJV/AB3NR +// Replace call to deprecated ftime() function with call to +// clock_gettime(2). clock_gettime(2) is POSIX.1 compliant. +// Replace ifdef __linux__ with autoconf generated guard. +// (Note __linux__ fails for *BSD, which all have better functions +// than the fallback Windows routine. Note, clock(2) on Unix systems +// returns CPU time used so far. It's not a "clock" in any generally +// accepted sense of the word. +// +// Check system call return codes and abort on failure. +// DJV/AB3NR + + struct timespec ts; + double curtime; + +// Do not know if CLOCK_MONOTONIC or CLOCK_REALTIME is appropriate. DJV + + if(clock_gettime(CLOCK_REALTIME, &ts)!=0) { + LOG_PERROR("clock_gettime"); + abort(); + } + curtime= ts.tv_nsec*1e-09 + (double)ts.tv_sec; + return curtime; +} +#else +#include +// This is much less accurate. +// Add compile time warning DJV/AB3NR +#warning imprecise clock() call in function current_time in wefax.cxx +static double current_time(void) +{ + clock_t clks = clock(); + + return clks * 1.0 / CLOCKS_PER_SEC; +} +#endif // HAVE_CLOCK_GETTIME +#endif //__WIN32__ /// Callback continuously called by fldigi modem class. int wefax::rx_process(const double *buf, int len)