diff --git a/configure.ac b/configure.ac index 9a527b41..ef307a6b 100644 --- a/configure.ac +++ b/configure.ac @@ -42,16 +42,6 @@ AC_ARG_ENABLE([libbsd-feature-test], AC_CHECK_FUNCS([err errx warn warnx],, [LIBBSD_NEEDED=yes]) AC_CHECK_HEADERS([sys/queue.h],, [LIBBSD_NEEDED=yes]) -AC_CHECK_FUNCS([clock_nanosleep],, [ - AC_COMPILE_IFELSE([ - AC_LANG_SOURCE([ - #include - #if !defined(timespecsub) || !defined(timespeccmp) - #error "timespecsub or timespeccmp not found" - #endif - ]) - ],, [LIBBSD_NEEDED=yes]) -]) # libbsd is obligatory on systems that don't have the BSD functions we use. # Pass "--enable-libbsd-feature-test" to ./configure, and the configure script # will tell you whether the library is a dependency. This option is intended to @@ -78,9 +68,10 @@ AC_SUBST([CPPFLAGS], ["$X11_CFLAGS $XCOMPOSITE_CFLAGS $XEXT_CFLAGS \ # Checks for header files. AC_CHECK_HEADERS([stdint.h sys/time.h unistd.h]) -# Required: Checks for library functions. +# Checks for library functions. AC_CHECK_FUNCS([getopt_long getsubopt gethostname strdup strerror strndup strtol],, AC_MSG_ERROR([required functions are not present.])) +AC_CHECK_FUNCS([clock_nanosleep]) AC_CONFIG_FILES([Makefile src/Makefile]) AC_OUTPUT diff --git a/src/scrot.c b/src/scrot.c index f67f27b4..3eabb9bb 100644 --- a/src/scrot.c +++ b/src/scrot.c @@ -43,7 +43,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include -#include #include #include @@ -323,7 +322,17 @@ static void scrotWaitUntil(const struct timespec *time) struct timespec tmp; do { clock_gettime(CLOCK_MONOTONIC, &tmp); - timespecsub(time, &tmp, &tmp); + + /* XXX: Use timespecsub(). OS X doesn't have that BSD macro, and libbsd + * doesn't support OS X save for an unmaintained fork. libobsd supports + * OS X but doesn't have the macro yet. + */ + tmp.tv_sec = time->tv_sec - tmp.tv_sec; + tmp.tv_nsec = time->tv_nsec - tmp.tv_nsec; + if (tmp.tv_nsec < 0) { + tmp.tv_sec--; + tmp.tv_nsec += 1000000000L; + } } while (nanosleep(&tmp, &tmp) == -1 && errno == EINTR); #endif errno = savedErrno;