time32.c 237 B

123456789101112131415
  1. #include "time32.h"
  2. #include <time.h>
  3. #include <errno.h>
  4. #include <stdint.h>
  5. time32_t __time32(time32_t *p)
  6. {
  7. time_t t = time(0);
  8. if (t < INT32_MIN || t > INT32_MAX) {
  9. errno = EOVERFLOW;
  10. return -1;
  11. }
  12. if (p) *p = t;
  13. return t;
  14. }