2 * Copyright (C) 2001-2003 by NBMK Encryption Technologies.
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>.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
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.
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.
35 /*****************************************************************************
36 * @(#) n8_time.h 1.4@(#)
37 *****************************************************************************/
39 /*****************************************************************************/
41 * @brief Time manipulation functions in a os independent manner.
43 * This file contains the data structures and function prototypes needed
44 * to manipulate time values in an OS independent manner.
46 *****************************************************************************/
48 /*****************************************************************************
50 * 03/12/03 jpw Added n8_delay_ms
51 * 08/17/01 msz Original version.
52 ****************************************************************************/
56 #include "n8_pub_types.h"
57 #include "n8_pub_errors.h"
59 /*****************************************************************************
61 *****************************************************************************/
63 #define N8_MICROSECS_IN_SECOND 1000000
65 /*****************************************************************************
66 * Structures/type definitions
67 *****************************************************************************/
71 uint32_t tv_sec
; /* Seconds. */
72 uint32_t tv_usec
; /* Microseconds. */
76 /*****************************************************************************
78 *****************************************************************************/
80 /* Get current timeval */
82 n8_gettime( n8_timeval_t
*n8_timeResults
);
84 /* Get seconds from timeval */
86 n8_timesecs( n8_timeval_t
*n8_timeResults
);
88 /* Get microseconds from timeval */
90 n8_timeusecs( n8_timeval_t
*n8_timeResults
);
92 /* Subtract two n8_timevals, n8_timeResults = n8_time2 - n8_time1 */
94 n8_subtime( n8_timeval_t
*n8_timeResults
,
95 n8_timeval_t
*n8_time2
,
96 n8_timeval_t
*n8_time1
);
98 /* Add two n8_timevals, n8_timeResults = n8_time2 + n8_time1 */
100 n8_addtime( n8_timeval_t
*n8_timeResults
,
101 n8_timeval_t
*n8_time2
,
102 n8_timeval_t
*n8_time1
);
104 /* Sleep usec seconds. */
106 n8_usleep(unsigned int usecs
);
109 /* Sleep milliseconds. */
111 n8_delay_ms(unsigned int milliseconds
);