summaryrefslogtreecommitdiff
path: root/libguile/scmsigs.c
diff options
context:
space:
mode:
authorJim Blandy <jimb@red-bean.com>1998-10-13 23:17:34 +0000
committerJim Blandy <jimb@red-bean.com>1998-10-13 23:17:34 +0000
commitb74f4728914a335d841b42d2a8f7968aad0be166 (patch)
tree882f254eacfed72e02a0e012094b82075e615752 /libguile/scmsigs.c
parent6aa9316dea8f1eb68a36c590ded0460ab9fcd28b (diff)
downloadguile-b74f4728914a335d841b42d2a8f7968aad0be166.tar.gz
* threads.h (scm_thread_usleep, scm_thread_sleep): New declarations.
* scmsigs.c (usleep): Clean up oddities declaring usleep; since we're just using it, not redefining it, we can use a K&R style declaration here. (sleep): Declare this, too, if the system hasn't. (scm_sleep, scm_usleep): Use scm_thread_sleep and scm_uthread_sleep if they're available; otherwise, just call the system functions. * scmconfig.h.in: Regenerated.
Diffstat (limited to 'libguile/scmsigs.c')
-rw-r--r--libguile/scmsigs.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c
index 9d7ced3ce..66cb7fa6a 100644
--- a/libguile/scmsigs.c
+++ b/libguile/scmsigs.c
@@ -52,12 +52,17 @@
#include <unistd.h>
#endif
-#if defined(MISSING_USLEEP_DECL) || (defined(GUILE_ISELECT) && !defined(HAVE_USLEEP))
-#ifdef USLEEP_RETURNS_VOID
-extern void usleep (USLEEP_ARG_TYPE);
-#else
-extern int usleep (USLEEP_ARG_TYPE);
+/* The thread system has its own sleep and usleep functions. */
+#ifndef USE_THREADS
+
+#if defined(MISSING_SLEEP_DECL)
+int sleep ();
+#endif
+
+#if defined(HAVE_USLEEP) && defined(MISSING_USLEEP_DECL)
+int usleep ();
#endif
+
#endif
@@ -353,32 +358,44 @@ SCM
scm_sleep (i)
SCM i;
{
- unsigned int j;
+ unsigned long j;
SCM_ASSERT (SCM_INUMP (i) && (SCM_INUM (i) >= 0), i, SCM_ARG1, s_sleep);
+#ifdef USE_THREADS
+ j = scm_thread_sleep (SCM_INUM(i));
+#else
j = sleep (SCM_INUM(i));
- return SCM_MAKINUM (j);
+#endif
+ return scm_ulong2num (j);
}
-#if defined(GUILE_ISELECT) || defined(HAVE_USLEEP)
+#if defined(USE_THREADS) || defined(HAVE_USLEEP)
SCM_PROC(s_usleep, "usleep", 1, 0, 0, scm_usleep);
SCM
scm_usleep (i)
SCM i;
{
-#ifndef USLEEP_RETURNS_VOID
- int j;
-#endif
SCM_ASSERT (SCM_INUMP (i) && (SCM_INUM (i) >= 0), i, SCM_ARG1, s_usleep);
+
+#ifdef USE_THREADS
+ /* If we have threads, we use the thread system's sleep function. */
+ {
+ unsigned long j = scm_thread_usleep (SCM_INUM (i));
+ return scm_ulong2num (j);
+ }
+#else
#ifdef USLEEP_RETURNS_VOID
usleep (SCM_INUM (i));
return SCM_INUM0;
#else
- j = usleep (SCM_INUM (i));
- return SCM_MAKINUM (j);
+ {
+ int j = usleep (SCM_INUM (i));
+ return SCM_MAKINUM (j);
+ }
#endif
-}
#endif
+}
+#endif /* GUILE_ISELECT || HAVE_USLEEP */
SCM_PROC(s_raise, "raise", 1, 0, 0, scm_raise);