1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 05:50:26 +02:00

* 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.
This commit is contained in:
Jim Blandy 1998-10-13 23:17:34 +00:00
parent 6aa9316dea
commit b74f472891
3 changed files with 41 additions and 21 deletions

View file

@ -167,21 +167,18 @@
/* Define if the operating system supplies bzero without declaring it. */
#undef MISSING_BZERO_DECL
/* Define if the operating system supplies strptime without declaring it. */
#undef MISSING_STRPTIME_DECL
/* Define if the operating system supplies sleep without declaring it. */
#undef MISSING_SLEEP_DECL
/* Define if the operating system supplies usleep without declaring it. */
#undef MISSING_USLEEP_DECL
/* Define if the operating system supplies strptime without declaring it. */
#undef MISSING_STRPTIME_DECL
/* Define if usleep doesn't return a value. */
/* Define if the system headers declare usleep to return void. */
#undef USLEEP_RETURNS_VOID
/* Define to be the type of the argument to usleep. */
#undef USLEEP_ARG_TYPE
/* Define if your readline library has the rl_getc_function variable. */
#undef HAVE_RL_GETC_FUNCTION

View file

@ -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
#endif /* GUILE_ISELECT || HAVE_USLEEP */
SCM_PROC(s_raise, "raise", 1, 0, 0, scm_raise);

View file

@ -76,6 +76,12 @@ SCM scm_threads_monitor SCM_P ((void));
SCM scm_spawn_thread (scm_catch_body_t body, void *body_data,
scm_catch_handler_t handler, void *handler_data);
/* These are versions of the ordinary sleep and usleep functions,
that play nicely with the thread system. */
SCM unsigned long scm_thread_sleep (unsigned long);
SCM unsigned long scm_thread_usleep (unsigned long);
/* The C versions of the Scheme-visible thread functions. */
#ifdef USE_COOP_THREADS
extern SCM scm_single_thread_p (void);