xref: /third_party/musl/compat/time32/timespec_get_time32.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/musl/compat/time32/
1570af302Sopenharmony_ci#include "time32.h"
2570af302Sopenharmony_ci#include <time.h>
3570af302Sopenharmony_ci#include <errno.h>
4570af302Sopenharmony_ci#include <stdint.h>
5570af302Sopenharmony_ci
6570af302Sopenharmony_ciint __timespec_get_time32(struct timespec32 *ts32, int base)
7570af302Sopenharmony_ci{
8570af302Sopenharmony_ci	struct timespec ts;
9570af302Sopenharmony_ci	int r = timespec_get(&ts, base);
10570af302Sopenharmony_ci	if (!r) return r;
11570af302Sopenharmony_ci	if (ts.tv_sec < INT32_MIN || ts.tv_sec > INT32_MAX) {
12570af302Sopenharmony_ci		errno = EOVERFLOW;
13570af302Sopenharmony_ci		return 0;
14570af302Sopenharmony_ci	}
15570af302Sopenharmony_ci	ts32->tv_sec = ts.tv_sec;
16570af302Sopenharmony_ci	ts32->tv_nsec = ts.tv_nsec;
17570af302Sopenharmony_ci	return r;
18570af302Sopenharmony_ci}
19

Indexes created Thu Nov 07 10:32:03 CST 2024