summaryrefslogtreecommitdiff
path: root/libhw_cr/host_util.h
blob: 7e559ef1aa493b5583845ca6f50359491d9e54ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* libhw_cr/host_util.h - Utilities for GNU/Linux hosts
 *
 * Copyright (C) 2024-2025  Luke T. Shumaker <lukeshu@lukeshu.com>
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

#ifndef _LIBHW_CR_HOST_UTIL_H_
#define _LIBHW_CR_HOST_UTIL_H_

#include <stdint.h>   /* for uint{n}_t */
#include <sys/time.h> /* for struct timeval */
#include <time.h>     /* for struct timespec */

#include <libmisc/error.h> /* for _errnum, error */

int host_sigrt_alloc(void);

typedef struct timeval  host_us_time_t;
typedef struct timespec host_ns_time_t;

host_us_time_t ns_to_host_us_time(uint64_t time_ns);
host_ns_time_t ns_to_host_ns_time(uint64_t time_ns);
uint64_t ns_from_host_us_time(host_us_time_t host_time);
uint64_t ns_from_host_ns_time(host_ns_time_t host_time);

#define host_errno_t int
_errnum errno_host2lm(host_errno_t host);
error errno2lm(host_errno_t host);

#endif /* _LIBHW_CR_HOST_UTIL_H_ */