time.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. Copyright (C) 2014 Olivier Marty <olivier.marty.m at gmail.com>
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  14. */
  15. #ifndef H_TIME
  16. #define H_TIME
  17. #include <time.h>
  18. typedef struct timespec mytime;
  19. void timeInitialize(int rel); // add rel seconds to the clock
  20. mytime timeGetRelative();
  21. // return -2 if t is in the past
  22. int timeSleepUntil(mytime t);
  23. int timeInFuture(mytime t);
  24. mytime timeCreate(time_t s, long ns);
  25. // return -2 if t is negative
  26. int timeSleep(mytime t);
  27. mytime timeDiff(mytime a, mytime b);
  28. // f should be >= 0
  29. // this function was wrong, now it returns a
  30. mytime timeFactor(mytime a, double f);
  31. void timePause(int pause); // pause and resume the clock
  32. int timeIsPaused();
  33. #endif