daily pastebin goal
39%
SHARE
TWEET

Untitled

a guest Feb 18th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     struct timespec end_time;
  2.     struct timespec current_time;
  3.    
  4.     double shocktimesec_s = floor(shocktimesec);
  5.     double shocktimesec_ns = (shocktimesec - floor(shocktimesec)) * 1e9;
  6.  
  7.     clock_gettime(CLOCK_MONOTONIC, &end_time);
  8.  
  9.     if ((end_time.tv_nsec + shocktimesec_ns ) < 1.00) {
  10.         end_time.tv_sec = end_time.tv_sec + shocktimesec_s;
  11.         end_time.tv_nsec = end_time.tv_nsec + shocktimesec_ns;
  12.     } else {
  13.         end_time.tv_sec = end_time.tv_sec + shocktimesec_s + 1;
  14.         end_time.tv_nsec = (end_time.tv_nsec + shocktimesec_ns) - 1;
  15.     }
  16.  
  17.     long double end_time_value = end_time.tv_sec + (end_time.tv_nsec / 1e9);
  18.  
  19.     long double current_time_value = 0;
  20.  
  21.     do {
  22.        
  23.         // do stuff here!
  24.  
  25.         clock_gettime(CLOCK_MONOTONIC, &current_time);
  26.  
  27.         current_time_value = current_time.tv_sec + (current_time.tv_nsec / 1e9);
  28.         printf("current time: %f", current_time_value);
  29.         printf("end time: %f", end_time_value);
  30.        
  31.  
  32.  
  33.  
  34.         } while (current_time_value < end_time_value);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top