Add replacement sleep(); mostly for mingw usage.

merge-requests/1/head
Chris Bagwell 2011-11-10 19:21:13 -06:00
rodzic 3125506715
commit 9c4f8d51d0
6 zmienionych plików z 54 dodań i 7 usunięć

13
configure vendored
Wyświetl plik

@ -9467,6 +9467,19 @@ esac
fi
ac_fn_c_check_func "$LINENO" "sleep" "ac_cv_func_sleep"
if test "x$ac_cv_func_sleep" = xyes; then :
$as_echo "#define HAVE_SLEEP 1" >>confdefs.h
else
case " $LIBOBJS " in
*" sleep.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS sleep.$ac_objext"
;;
esac
fi
ac_fn_c_check_func "$LINENO" "syslog" "ac_cv_func_syslog"
if test "x$ac_cv_func_syslog" = xyes; then :
$as_echo "#define HAVE_SYSLOG 1" >>confdefs.h

Wyświetl plik

@ -306,7 +306,7 @@ AC_CHECK_FUNCS(atexit ioperm i386_set_ioperm \
cfmakeraw tcsendbreak strcasecmp strncasecmp _portaccess \
getaddrinfo getnameinfo poll setitimer iopl getuid getpass)
AC_REPLACE_FUNCS(getenv isfdtype sigprocmask snprintf \
strcasestr strdup strndup strsep usleep syslog vsyslog)
strcasestr strdup strndup strsep usleep sleep syslog vsyslog)
SANE_PROTOTYPES

Wyświetl plik

@ -267,6 +267,9 @@
/* Define to 1 if you have the `sigprocmask' function. */
#undef HAVE_SIGPROCMASK
/* Define to 1 if you have the `sleep' function. */
#undef HAVE_SLEEP
/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF

Wyświetl plik

@ -10,5 +10,5 @@ noinst_LTLIBRARIES = liblib.la libfelib.la
libfelib_la_SOURCES = getopt.c getopt1.c md5.c syslog.c vsyslog.c
liblib_la_SOURCES = alloca.c getenv.c inet_ntop.c inet_pton.c \
isfdtype.c sigprocmask.c snprintf.c strcasestr.c strdup.c \
strndup.c strsep.c usleep.c
isfdtype.c sigprocmask.c sleep.c snprintf.c strcasestr.c \
strdup.c strndup.c strsep.c usleep.c

Wyświetl plik

@ -53,8 +53,8 @@ am_libfelib_la_OBJECTS = getopt.lo getopt1.lo md5.lo syslog.lo \
libfelib_la_OBJECTS = $(am_libfelib_la_OBJECTS)
liblib_la_LIBADD =
am_liblib_la_OBJECTS = alloca.lo getenv.lo inet_ntop.lo inet_pton.lo \
isfdtype.lo sigprocmask.lo snprintf.lo strcasestr.lo strdup.lo \
strndup.lo strsep.lo usleep.lo
isfdtype.lo sigprocmask.lo sleep.lo snprintf.lo strcasestr.lo \
strdup.lo strndup.lo strsep.lo usleep.lo
liblib_la_OBJECTS = $(am_liblib_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include/sane
depcomp = $(SHELL) $(top_srcdir)/depcomp
@ -247,8 +247,8 @@ AM_CPPFLAGS = -I. -I$(top_builddir)/include -I$(top_srcdir)/include
noinst_LTLIBRARIES = liblib.la libfelib.la
libfelib_la_SOURCES = getopt.c getopt1.c md5.c syslog.c vsyslog.c
liblib_la_SOURCES = alloca.c getenv.c inet_ntop.c inet_pton.c \
isfdtype.c sigprocmask.c snprintf.c strcasestr.c strdup.c \
strndup.c strsep.c usleep.c
isfdtype.c sigprocmask.c sleep.c snprintf.c strcasestr.c \
strdup.c strndup.c strsep.c usleep.c
all: all-am
@ -313,6 +313,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isfdtype.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sigprocmask.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sleep.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snprintf.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strcasestr.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strdup.Plo@am__quote@

30
lib/sleep.c 100644
Wyświetl plik

@ -0,0 +1,30 @@
#include "../include/sane/config.h"
#ifndef HAVE_SLEEP
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
unsigned int sleep(unsigned int seconds)
{
#ifdef HAVE_WINDOWS_H
Sleep(seconds*1000);
return 0;
#else
int rc = 0;
/* WARNING: Not all platforms support usleep() for more than 1
* second. Assuming if they do not have POSIX sleep then they
* do not have POSIX usleep() either and are using our internal
* version which can support it. If it fails, need to add an OS
* specific replacement like Sleep for Windows.
*/
if (usleep(seconds*1000000))
rc = 1;
return rc;
#endif
}
#endif