14fc55e3eSMaxim Sobolev /* 24fc55e3eSMaxim Sobolev * Copyright (c) 2004-2016 Maxim Sobolev <sobomax@FreeBSD.org> 34fc55e3eSMaxim Sobolev * All rights reserved. 44fc55e3eSMaxim Sobolev * 54fc55e3eSMaxim Sobolev * Redistribution and use in source and binary forms, with or without 64fc55e3eSMaxim Sobolev * modification, are permitted provided that the following conditions 74fc55e3eSMaxim Sobolev * are met: 84fc55e3eSMaxim Sobolev * 1. Redistributions of source code must retain the above copyright 94fc55e3eSMaxim Sobolev * notice, this list of conditions and the following disclaimer. 104fc55e3eSMaxim Sobolev * 2. Redistributions in binary form must reproduce the above copyright 114fc55e3eSMaxim Sobolev * notice, this list of conditions and the following disclaimer in the 124fc55e3eSMaxim Sobolev * documentation and/or other materials provided with the distribution. 134fc55e3eSMaxim Sobolev * 144fc55e3eSMaxim Sobolev * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 154fc55e3eSMaxim Sobolev * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 164fc55e3eSMaxim Sobolev * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 174fc55e3eSMaxim Sobolev * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 184fc55e3eSMaxim Sobolev * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 194fc55e3eSMaxim Sobolev * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 204fc55e3eSMaxim Sobolev * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 214fc55e3eSMaxim Sobolev * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 224fc55e3eSMaxim Sobolev * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 234fc55e3eSMaxim Sobolev * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 244fc55e3eSMaxim Sobolev * SUCH DAMAGE. 254fc55e3eSMaxim Sobolev */ 264fc55e3eSMaxim Sobolev 274fc55e3eSMaxim Sobolev #include <sys/cdefs.h> 284fc55e3eSMaxim Sobolev __FBSDID("$FreeBSD$"); 294fc55e3eSMaxim Sobolev 304fc55e3eSMaxim Sobolev #include <math.h> 314fc55e3eSMaxim Sobolev #include <stdint.h> 324fc55e3eSMaxim Sobolev #include <time.h> 334fc55e3eSMaxim Sobolev 344fc55e3eSMaxim Sobolev #include "mkuz_time.h" 354fc55e3eSMaxim Sobolev 364fc55e3eSMaxim Sobolev double 374fc55e3eSMaxim Sobolev getdtime(void) 384fc55e3eSMaxim Sobolev { 394fc55e3eSMaxim Sobolev struct timespec tp; 404fc55e3eSMaxim Sobolev 414fc55e3eSMaxim Sobolev if (clock_gettime(CLOCK_MONOTONIC, &tp) == -1) 424fc55e3eSMaxim Sobolev return (-1); 434fc55e3eSMaxim Sobolev 444fc55e3eSMaxim Sobolev return timespec2dtime(&tp); 454fc55e3eSMaxim Sobolev } 46