1/*- 2 * Copyright (C) 2001-2003 by NBMK Encryption Technologies. 3 * All rights reserved. 4 * 5 * NBMK Encryption Technologies provides no support of any kind for 6 * this software. Questions or concerns about it may be addressed to 7 * the members of the relevant open-source community at 8 * <tech-crypto@netbsd.org>. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions are 12 * met: 13 * 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 17 * 2. Redistributions in binary form must reproduce the above 18 * copyright notice, this list of conditions and the following 19 * disclaimer in the documentation and/or other materials provided 20 * with the distribution. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35/***************************************************************************** 36 * @(#) n8_time.h 1.4@(#) 37 *****************************************************************************/ 38 39/*****************************************************************************/ 40/** @file n8_time.h 41 * @brief Time manipulation functions in a os independent manner. 42 * 43 * This file contains the data structures and function prototypes needed 44 * to manipulate time values in an OS independent manner. 45 * 46 *****************************************************************************/ 47 48/***************************************************************************** 49 * Revision history: 50 * 03/12/03 jpw Added n8_delay_ms 51 * 08/17/01 msz Original version. 52 ****************************************************************************/ 53#ifndef _N8_TIME_H 54#define _N8_TIME_H 55 56#include "n8_pub_types.h" 57#include "n8_pub_errors.h" 58 59/***************************************************************************** 60 * #defines 61 *****************************************************************************/ 62 63#define N8_MICROSECS_IN_SECOND 1000000 64 65/***************************************************************************** 66 * Structures/type definitions 67 *****************************************************************************/ 68 69typedef struct 70{ 71 uint32_t tv_sec; /* Seconds. */ 72 uint32_t tv_usec; /* Microseconds. */ 73} n8_timeval_t; 74 75 76/***************************************************************************** 77 * Function prototypes 78 *****************************************************************************/ 79 80/* Get current timeval */ 81N8_Status_t 82n8_gettime( n8_timeval_t *n8_timeResults ); 83 84/* Get seconds from timeval */ 85uint32_t 86n8_timesecs( n8_timeval_t *n8_timeResults ); 87 88/* Get microseconds from timeval */ 89uint32_t 90n8_timeusecs( n8_timeval_t *n8_timeResults ); 91 92/* Subtract two n8_timevals, n8_timeResults = n8_time2 - n8_time1 */ 93N8_Status_t 94n8_subtime( n8_timeval_t *n8_timeResults, 95 n8_timeval_t *n8_time2, 96 n8_timeval_t *n8_time1 ); 97 98/* Add two n8_timevals, n8_timeResults = n8_time2 + n8_time1 */ 99N8_Status_t 100n8_addtime( n8_timeval_t *n8_timeResults, 101 n8_timeval_t *n8_time2, 102 n8_timeval_t *n8_time1 ); 103 104/* Sleep usec seconds. */ 105N8_Status_t 106n8_usleep(unsigned int usecs); 107 108#if 0 109/* Sleep milliseconds. */ 110N8_Status_t 111n8_delay_ms(unsigned int milliseconds); 112#endif 113 114#endif 115