-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1996, 1997, 2003
+ * Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* implied warranty.
*/
-#if __STDC__
-#include <stdlib.h>
-#endif
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#else /* !HAVE_CONFIG_H */
+# ifndef NO_SELECT
+# define HAVE_SELECT
+# endif
+#endif /* !HAVE_CONFIG_H */
-#include <X11/Xlib.h>
-#include <X11/Xos.h> /* lazy way out */
+#ifdef __STDC__
+# include <stdlib.h>
+#endif
-#ifdef VMS
-#include <descrip.h>
-#include <stdio.h>
-extern char *progname;
-#include <lib$routines.h>
-unsigned long int statvms;
-float seconds;
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
#endif
-/* usleep() doesn't exist everywhere, and select() is faster anyway.
- */
+#if defined(VMS)
+# include <descrip.h>
+# include <stdio.h>
+# include <lib$routines.h>
+#elif defined(HAVE_SELECT)
+# include <sys/time.h> /* for struct timeval */
+#endif
-#ifndef VMS
-#ifdef NO_SELECT
- /* If you don't have select() or usleep(), I guess you lose...
- Maybe you have napms() instead? Let me know.
- */
-void
-screenhack_usleep (usecs)
- unsigned long usecs;
-{
- usleep (usecs);
-}
+#ifdef __SCREENHACK_USLEEP_H__
+ERROR, do not include that here
+#endif
-#else /* ! NO_SELECT */
+extern void screenhack_usleep (unsigned long usecs); /* suppress warning */
void
-screenhack_usleep (usecs)
- unsigned long usecs;
+screenhack_usleep (unsigned long usecs)
{
+# if defined(VMS)
+ float seconds = ((float) usecs)/1000000.0;
+ unsigned long int statvms = lib$wait(&seconds);
+
+#elif defined(HAVE_SELECT)
+ /* usleep() doesn't exist everywhere, and select() is faster anyway. */
struct timeval tv;
tv.tv_sec = usecs / 1000000L;
tv.tv_usec = usecs % 1000000L;
(void) select (0, 0, 0, 0, &tv);
-}
-#endif /* ! NO_SELECT */
-
-#else /* VMS */
-
-#define SEC_DELTA "0000 00:00:01.00"
-#define TICK_DELTA "0000 00:00:00.08"
-static int bin_sec_delta[2], bin_tick_delta[2], deltas_set = 0;
-
-static void
-set_deltas ()
-{
- int status;
- extern int SYS$BINTIM ();
- $DESCRIPTOR (str_sec_delta, SEC_DELTA);
- $DESCRIPTOR (str_tick_delta, TICK_DELTA);
- if (!deltas_set)
- {
- status = SYS$BINTIM (&str_sec_delta, &bin_sec_delta);
- if (!(status & 1))
- {
- fprintf (stderr, "%s: cannot convert delta time ", progname);
- fprintf (stderr, SEC_DELTA);
- fprintf (stderr, "; status code = %d\n", status);
- exit (status);
- }
- status = SYS$BINTIM (&str_tick_delta, &bin_tick_delta);
- if (!(status & 1))
- {
- fprintf (stderr, "%s: cannot convert delta time ", progname);
- fprintf (stderr, TICK_DELTA);
- fprintf (stderr, "; status code = %d\n", status);
- exit (status);
- }
- deltas_set = 1;
- }
-}
-
-void
-screenhack_usleep (usecs)
- unsigned long usecs;
-{
- int status, *bin_delta;
-
-/* extern int SYS$SCHWDK (), SYS$HIBER (); */
-/*#define TICK_INTERVAL 1000 */
-/* */
-/* if (!deltas_set) set_deltas (); */
-/* bin_delta = (usecs == TICK_INTERVAL) ? &bin_tick_delta : &bin_sec_delta; */
-/* status = SYS$SCHDWK (0, 0, bin_delta, 0); */
-/* if ((status & 1)) (void) SYS$HIBER (); */
+#else /* !VMS && !HAVE_SELECT */
+ /* If you don't have select() or usleep(), I guess you lose...
+ Maybe you have napms() instead? Let me know. */
+ usleep (usecs);
- seconds = ((float) usecs)/1000000.0;
- statvms = lib$wait(&seconds);
+#endif /* !VMS && !HAVE_SELECT */
}
-
-#endif /*VMS */