1298504Ssobomax/* 2298504Ssobomax * Copyright (c) 2004-2016 Maxim Sobolev <sobomax@FreeBSD.org> 3298504Ssobomax * All rights reserved. 4298504Ssobomax * 5298504Ssobomax * Redistribution and use in source and binary forms, with or without 6298504Ssobomax * modification, are permitted provided that the following conditions 7298504Ssobomax * are met: 8298504Ssobomax * 1. Redistributions of source code must retain the above copyright 9298504Ssobomax * notice, this list of conditions and the following disclaimer. 10298504Ssobomax * 2. Redistributions in binary form must reproduce the above copyright 11298504Ssobomax * notice, this list of conditions and the following disclaimer in the 12298504Ssobomax * documentation and/or other materials provided with the distribution. 13298504Ssobomax * 14298504Ssobomax * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15298504Ssobomax * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16298504Ssobomax * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17298504Ssobomax * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18298504Ssobomax * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19298504Ssobomax * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20298504Ssobomax * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21298504Ssobomax * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22298504Ssobomax * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23298504Ssobomax * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24298504Ssobomax * SUCH DAMAGE. 25298504Ssobomax */ 26298504Ssobomax 27298504Ssobomax#include <sys/cdefs.h> 28298504Ssobomax__FBSDID("$FreeBSD: releng/11.0/usr.bin/mkuzip/mkuz_time.c 298504 2016-04-23 07:23:43Z sobomax $"); 29298504Ssobomax 30298504Ssobomax#include <math.h> 31298504Ssobomax#include <stdint.h> 32298504Ssobomax#include <time.h> 33298504Ssobomax 34298504Ssobomax#include "mkuz_time.h" 35298504Ssobomax 36298504Ssobomaxdouble 37298504Ssobomaxgetdtime(void) 38298504Ssobomax{ 39298504Ssobomax struct timespec tp; 40298504Ssobomax 41298504Ssobomax if (clock_gettime(CLOCK_MONOTONIC, &tp) == -1) 42298504Ssobomax return (-1); 43298504Ssobomax 44298504Ssobomax return timespec2dtime(&tp); 45298504Ssobomax} 46