summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Mistachkin <joe@mistachkin.com>2015-05-18 20:33:56 (GMT)
committerJoe Mistachkin <joe@mistachkin.com>2015-05-18 20:33:56 (GMT)
commit8c0a7dab9b12dda93f76637c8e32316148890b88 (patch)
tree9ac06e69edb62cbb5a23db9265d76689584f644d
parent193821f1117e26ef65b36062a8e5488450a3525c (diff)
downloadtcl-8c0a7dab9b12dda93f76637c8e32316148890b88.zip
tcl-8c0a7dab9b12dda93f76637c8e32316148890b88.tar.gz
tcl-8c0a7dab9b12dda93f76637c8e32316148890b88.tar.bz2
First attempt at implementing the necessary auto-magic for usleep.
-rw-r--r--unix/configure.in6
-rw-r--r--unix/tcl.m442
-rw-r--r--unix/tclUnixThrd.c8
3 files changed, 48 insertions, 8 deletions
diff --git a/unix/configure.in b/unix/configure.in
index c7b0edc..ce68391 100644
--- a/unix/configure.in
+++ b/unix/configure.in
@@ -545,6 +545,12 @@ if test $tcl_cv_putenv_copy = yes; then
fi
#--------------------------------------------------------------------
+# Check for support of usleep function
+#--------------------------------------------------------------------
+
+SC_ENABLE_USLEEP
+
+#--------------------------------------------------------------------
# Check for support of nl_langinfo function
#--------------------------------------------------------------------
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index 25c2699..3ffdcd4 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -774,6 +774,48 @@ AC_DEFUN([SC_ENABLE_SYMBOLS], [
])
#------------------------------------------------------------------------
+# SC_ENABLE_USLEEP --
+#
+# Allows use of usleep function.
+# This is only relevant for Unix.
+#
+# Arguments:
+# none
+#
+# Results:
+#
+# Adds the following arguments to configure:
+# --enable-usleep=yes|no (default is yes)
+#
+# Defines the following vars:
+# HAVE_USLEEP Triggers use of usleep if defined.
+#------------------------------------------------------------------------
+
+AC_DEFUN([SC_ENABLE_USLEEP], [
+ AC_ARG_ENABLE(usleep,
+ AC_HELP_STRING([--enable-usleep],
+ [use usleep if possible to sleep, otherwise use Tcl_Sleep (default: on)]),
+ [usleep_ok=$enableval], [usleep_ok=yes])
+
+ HAVE_USLEEP=0
+ if test "$usleep_ok" = "yes"; then
+ AC_CHECK_HEADER(unistd.h,[usleep_ok=yes],[usleep_ok=no])
+ fi
+ AC_MSG_CHECKING([whether to use usleep])
+ if test "$usleep_ok" = "yes"; then
+ AC_CACHE_VAL(tcl_cv_usleep_h, [
+ AC_TRY_COMPILE([#include <unistd.h>], [usleep(0);],
+ [tcl_cv_usleep_h=yes],[tcl_cv_usleep_h=no])])
+ AC_MSG_RESULT([$tcl_cv_usleep_h])
+ if test $tcl_cv_usleep_h = yes; then
+ AC_DEFINE(HAVE_USLEEP, 1, [Do we have usleep()?])
+ fi
+ else
+ AC_MSG_RESULT([$usleep_ok])
+ fi
+])
+
+#------------------------------------------------------------------------
# SC_ENABLE_LANGINFO --
#
# Allows use of modern nl_langinfo check for better l10n.
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index 2cb2d87..3963f84 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -35,14 +35,6 @@ static Tcl_ThreadDataKey dataKey;
#endif
/*
- * TODO: Remove this section and add the necessary "auto* magic".
- */
-
-#ifndef HAVE_USLEEP
-# define HAVE_USLEEP
-#endif
-
-/*
* masterLock is used to serialize creation of mutexes, condition variables,
* and thread local storage. This is the only place that can count on the
* ability to statically initialize the mutex.