From: Stacey Son <s...@freebsd.org> os-time.c contains various functions to convert FreeBSD-specific time structure between host and guest formats
Signed-off-by: Ajeets6 <itachis6...@gmail.com> Signed-off-by: Stacey Son <s...@freebsd.org> --- bsd-user/freebsd/os-time.c | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 bsd-user/freebsd/os-time.c diff --git a/bsd-user/freebsd/os-time.c b/bsd-user/freebsd/os-time.c new file mode 100644 index 0000000000..ec9f59ded7 --- /dev/null +++ b/bsd-user/freebsd/os-time.c @@ -0,0 +1,41 @@ +/* + * FreeBSD time related system call helpers + * + * Copyright (c) 2013-15 Stacey D. Son + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <http://www.gnu.org/licenses/>. + */ + +/* + * FreeBSD time conversion functions + */ +#include <errno.h> +#include <time.h> +#include <sys/types.h> +#include "qemu.h" + + +abi_long t2h_freebsd_timeval(struct timeval *tv, abi_ulong target_tv_addr) +{ + struct target_freebsd_timeval *target_tv; + + if (!lock_user_struct(VERIFY_READ, target_tv, target_tv_addr, 0)) { + return -TARGET_EFAULT; + } + __get_user(tv->tv_sec, &target_tv->tv_sec); + __get_user(tv->tv_usec, &target_tv->tv_usec); + unlock_user_struct(target_tv, target_tv_addr, 1); + + return 0; +} \ No newline at end of file -- 2.34.1