spencer@eecs.umich.edu (Spencer W. Thomas) (02/20/91)
The recently posted 'glx.c' file presumably works great on a Sun, but won't compile on my DEC 3100. Below is a diff listing of the changes I had to make to get it to run. (The problems were: needs to include sys/types.h, no usleep or strdup functions.) I'm thinking about modifying it to work better on an 8-bit display (blob looks pretty stupid at the moment). =Spencer W. Thomas EECS Dept, U of Michigan, Ann Arbor, MI 48109 spencer@eecs.umich.edu 313-936-2616 (8-6 E[SD]T M-F) *** glx.c~ Tue Feb 19 17:02:28 1991 --- glx.c Tue Feb 19 16:23:46 1991 *************** *** 27,32 **** --- 27,33 ---- */ #include <stdio.h> + #include <sys/types.h> #include <sys/times.h> #include <string.h> #include <strings.h> *************** *** 37,42 **** --- 38,45 ---- #include <X11/bitmaps/gray1> #include "gl.h" + extern char *strdup(); + #define POLYBATCH 40 #define FONTNAME "bembo-bold-24" *************** *** 325,330 **** --- 328,335 ---- sginap(len) int len; { + extern void usleep(); + usleep(len); } *************** *** 603,606 **** --- 608,674 ---- int mask; { /* NOP */ + } + + #include <signal.h> + #include <sys/time.h> + + #define USPS 1000000 /* number of microseconds in a second */ + #define TICK 10000 /* system clock resolution in microseconds */ + + static int ringring; + static void (*ofunc)(); + + static void + sleepx() + { + ringring = 1; + } + + void + set_timer(n) + unsigned n; + { + struct itimerval itv; + register struct itimerval *itp = &itv; + if (n == 0) + { + ringring = 1; + return; + } + timerclear(&itp->it_interval); + itp->it_value.tv_sec = n / USPS; + itp->it_value.tv_usec = n % USPS; + ofunc = (void (*)())signal(SIGALRM, sleepx); + + ringring = 0; + (void) setitimer(ITIMER_REAL, itp, (struct itimerval *)0); + } + + #ifndef sigmask + #define sigmask(m) (1 << ((m)-1)) + #endif + + void + wait_timer() + { + while (!ringring) + sigpause( ~sigmask(SIGALRM)); + signal(SIGALRM, ofunc); + } + + void + usleep(usex) + { + set_timer( usex ); + wait_timer(); + } + + char *strdup(s) + char *s; + { + char *s1 = (char *)malloc(1 + strlen(s)); + if ( s1 ) + strcpy( s1, s ); + return s1; } -- =Spencer W. Thomas EECS Dept, U of Michigan, Ann Arbor, MI 48109 spencer@eecs.umich.edu 313-936-2616 (8-6 E[SD]T M-F)