summaryrefslogtreecommitdiff
path: root/common/gettimeofday.c
blob: fce5c7e04e2ed7d8487b15528d4490a8504b5e6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* Copyright 2022 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "gettimeofday.h"
#include "timer.h"

#include <stddef.h>

enum ec_error_list ec_gettimeofday(struct timeval *restrict tv,
				   void *restrict tz)
{
	uint64_t now;

	if (tv == NULL)
		return EC_ERROR_INVAL;

	now = get_time().val;
	tv->tv_sec = now / SECOND;
	tv->tv_usec = now % SECOND;
	return EC_SUCCESS;
}