time.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) mlibc & plct lab
  3. *
  4. * SPDX-License-Identifier: MIT
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023/06/16 bernard the first verison
  9. */
  10. #ifndef MLIBC_TIME_H__
  11. #define MLIBC_TIME_H__
  12. #include "sys/types.h"
  13. typedef long time_t;
  14. typedef long clock_t;
  15. struct tm
  16. {
  17. int tm_sec;
  18. int tm_min;
  19. int tm_hour;
  20. int tm_mday;
  21. int tm_mon;
  22. int tm_year;
  23. int tm_wday;
  24. int tm_yday;
  25. int tm_isdst;
  26. long __tm_gmtoff;
  27. const char *__tm_zone;
  28. };
  29. struct timespec
  30. {
  31. time_t tv_sec; /* seconds */
  32. long tv_nsec; /* and nanoseconds */
  33. };
  34. struct itimerspec {
  35. struct timespec it_interval;
  36. struct timespec it_value;
  37. };
  38. #define CLOCK_REALTIME 0
  39. #define CLOCK_MONOTONIC 1
  40. #define CLOCK_PROCESS_CPUTIME_ID 2
  41. #define CLOCK_THREAD_CPUTIME_ID 3
  42. #define CLOCK_MONOTONIC_RAW 4
  43. #define CLOCK_REALTIME_COARSE 5
  44. #define CLOCK_MONOTONIC_COARSE 6
  45. #define CLOCK_BOOTTIME 7
  46. #define CLOCK_REALTIME_ALARM 8
  47. #define CLOCK_BOOTTIME_ALARM 9
  48. #define CLOCK_SGI_CYCLE 10
  49. #define CLOCK_TAI 11
  50. #define TIMER_ABSTIME 1
  51. struct tm* gmtime(const time_t* t);
  52. struct tm *gmtime_r(const time_t *timep, struct tm *r);
  53. struct tm* localtime_r(const time_t* t, struct tm* r);
  54. size_t strftime(char *s, size_t maxsize, const char *format, const struct tm *tp);
  55. time_t mktime(struct tm* const t);
  56. char* ctime(const time_t* tim_p);
  57. time_t time(time_t* t);
  58. #endif /*MLIBC_TIME_H__*/