st-flexipatch

My st-flexipatch configuration
git clone git://git.ethandl.dev/st-flexipatch
Log | Files | Refs | README | LICENSE

sync.c (375B)


      1 #include <time.h>
      2 struct timespec sutv;
      3 
      4 static void
      5 tsync_begin()
      6 {
      7 	clock_gettime(CLOCK_MONOTONIC, &sutv);
      8 	su = 1;
      9 }
     10 
     11 static void
     12 tsync_end()
     13 {
     14 	su = 0;
     15 }
     16 
     17 int
     18 tinsync(uint timeout)
     19 {
     20 	struct timespec now;
     21 	if (su && !clock_gettime(CLOCK_MONOTONIC, &now)
     22 	       && TIMEDIFF(now, sutv) >= timeout)
     23 		su = 0;
     24 	return su;
     25 }
     26 
     27 int
     28 ttyread_pending()
     29 {
     30 	return twrite_aborted;
     31 }