New paste Repaste Download
#include <stdio.h>
#include <time.h>
struct timespec *set_timer(struct timespec *ts, int ms) {
  clock_gettime(CLOCK_REALTIME, ts);
  ts->tv_sec += ms / 1000;
  ts->tv_nsec += (ms % 1000) * 1000000;
  return ts;
}
int main() {
  struct timespec now;
  clock_gettime(CLOCK_REALTIME, &now);
  set_timer(&now, 1000);
  printf("sec: %lld\n", now.tv_sec);
  printf("nsec: %ld\n", now.tv_nsec);
  return 0;
}
Filename: None. Size: 427b. View raw, , hex, or download this file.

This paste expires on 2024-05-17 09:14:36.646936. Pasted through web.