1570af302Sopenharmony_ci#define _GNU_SOURCE 2570af302Sopenharmony_ci#include "time32.h" 3570af302Sopenharmony_ci#include <time.h> 4570af302Sopenharmony_ci#include <errno.h> 5570af302Sopenharmony_ci#include <stdint.h> 6570af302Sopenharmony_ci 7570af302Sopenharmony_citime32_t __time32gm(struct tm *tm) 8570af302Sopenharmony_ci{ 9570af302Sopenharmony_ci time_t t = timegm(tm); 10570af302Sopenharmony_ci if (t < INT32_MIN || t > INT32_MAX) { 11570af302Sopenharmony_ci errno = EOVERFLOW; 12570af302Sopenharmony_ci return -1; 13570af302Sopenharmony_ci } 14570af302Sopenharmony_ci return t; 15570af302Sopenharmony_ci} 16