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
21 #include <X11/Xos.h> /* lazy way out */
23 /* usleep() doesn't exist everywhere, and select() is faster anyway.
29 /* If you don't have select() or usleep(), I guess you lose...
30 Maybe you have napms() instead? Let me know.
33 screenhack_usleep (usecs)
39 #else /* ! NO_SELECT */
42 screenhack_usleep (usecs)
46 tv.tv_sec = usecs / 1000000L;
47 tv.tv_usec = usecs % 1000000L;
48 (void) select (0, 0, 0, 0, &tv);
51 #endif /* ! NO_SELECT */
55 #define SEC_DELTA "0000 00:00:01.00"
56 #define TICK_DELTA "0000 00:00:00.08"
57 static int bin_sec_delta[2], bin_tick_delta[2], deltas_set = 0;
63 extern int SYS$BINTIM ();
64 $DESCRIPTOR (str_sec_delta, SEC_DELTA);
65 $DESCRIPTOR (str_tick_delta, TICK_DELTA);
68 status = SYS$BINTIM (&str_sec_delta, &bin_sec_delta);
71 fprintf (stderr, "%s: cannot convert delta time ", progname);
72 fprintf (stderr, SEC_DELTA);
73 fprintf (stderr, "; status code = %d\n", status);
76 status = SYS$BINTIM (&str_tick_delta, &bin_tick_delta);
79 fprintf (stderr, "%s: cannot convert delta time ", progname);
80 fprintf (stderr, TICK_DELTA);
81 fprintf (stderr, "; status code = %d\n", status);
89 screenhack_usleep (usecs)
92 int status, *bin_delta;
93 extern int SYS$SCHWDK (), SYS$HIBER ();
95 if (!deltas_set) set_deltas ();
96 bin_delta = (usecs == TICK_INTERVAL) ? &bin_tick_delta : &bin_sec_delta;
97 status = SYS$SCHDWK (0, 0, bin_delta, 0);
98 if ((status & 1)) (void) SYS$HIBER ();