1 /* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@lucid.com>
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
17 #include <X11/Xos.h> /* lazy way out */
19 /* usleep() doesn't exist everywhere, and select() is faster anyway.
25 /* If you don't have select() or usleep(), I guess you lose...
26 Maybe you have napms() instead? Let me know.
29 screenhack_usleep (usecs)
35 #else /* ! NO_SELECT */
38 screenhack_usleep (usecs)
42 tv.tv_sec = usecs / 1000000L;
43 tv.tv_usec = usecs % 1000000L;
44 (void) select (0, 0, 0, 0, &tv);
47 #endif /* ! NO_SELECT */
51 #define SEC_DELTA "0000 00:00:01.00"
52 #define TICK_DELTA "0000 00:00:00.08"
53 static int bin_sec_delta[2], bin_tick_delta[2], deltas_set = 0;
59 extern int SYS$BINTIM ();
60 $DESCRIPTOR (str_sec_delta, SEC_DELTA);
61 $DESCRIPTOR (str_tick_delta, TICK_DELTA);
64 status = SYS$BINTIM (&str_sec_delta, &bin_sec_delta);
67 fprintf (stderr, "%s: cannot convert delta time ", progname);
68 fprintf (stderr, SEC_DELTA);
69 fprintf (stderr, "; status code = %d\n", status);
72 status = SYS$BINTIM (&str_tick_delta, &bin_tick_delta);
75 fprintf (stderr, "%s: cannot convert delta time ", progname);
76 fprintf (stderr, TICK_DELTA);
77 fprintf (stderr, "; status code = %d\n", status);
85 screenhack_usleep (usecs)
88 int status, *bin_delta;
89 extern int SYS$SCHWDK (), SYS$HIBER ();
91 if (!deltas_set) set_deltas ();
92 bin_delta = (usecs == TICK_INTERVAL) ? &bin_tick_delta : &bin_sec_delta;
93 status = SYS$SCHDWK (0, 0, bin_delta, 0);
94 if ((status & 1)) (void) SYS$HIBER ();