⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rvtime.h

📁 基于h323协议的软phone
💻 H
字号:
/***********************************************************************
Filename   : rvtime.h
Description: rvtime header file
************************************************************************
      Copyright (c) 2001,2002 RADVISION Inc. and RADVISION Ltd.
************************************************************************
NOTICE:
This document contains information that is confidential and proprietary
to RADVISION Inc. and RADVISION Ltd.. No part of this document may be
reproduced in any form whatsoever without written prior approval by
RADVISION Inc. or RADVISION Ltd..

RADVISION Inc. and RADVISION Ltd. reserve the right to revise this
publication and make changes without obligation to notify any person of
such revisions or changes.
***********************************************************************/
/*$
{package:
	{name: Time}
	{superpackage: CUtils}
	{include: rvtime.h}
	{description:	
		{p: This module provides functions for creating and manipulating
			time values. Each time value is stored in two parts, seconds
			and nanoseconds. This is equivalent to the POSIX timespec structure
			except that accessor functions are provided, instead of accessing
			the structure directly.}
		{p: This modules also provides some basic time constants:}
		{bulletlist:
			{item: RV_TIME_NSECPERUSEC: Number of nanoseconds per microsecond (32 bit)}
			{item: RV_TIME_NSECPERMSEC: Number of nanoseconds per millisecond (32 bit)}
			{item: RV_TIME_NSECPERSEC: Number of nanoseconds per second (32 bit)}
			{item: RV_TIME64_NSECPERUSEC: Number of nanoseconds per microsecond (64 bit)}
			{item: RV_TIME64_NSECPERMSEC: Number of nanoseconds per millisecond (64 bit)}
			{item: RV_TIME64_NSECPERSEC: Number of nanoseconds per second (64 bit)}
		}
	}
	{notes:
		{note:  This module does no locking at all. Any locking of
				a time object is the responsibility of the user.}
	}
}
$*/
#ifndef RV_TIME_H
#define RV_TIME_H

#include "rvtypes.h"

/*$
{type:
	{name: RvTime}
	{superpackage: Time}
	{include: rvtime.h}
	{description:	
		{p: A time value in seconds and nanoseconds.}
	}
}
$*/
typedef struct {
	RvInt32 sec;
	RvInt32 nsec;
} RvTime;

/* Convenient constants */
#define RV_TIME_NSECPERUSEC RvInt32Const(1000)
#define RV_TIME_NSECPERMSEC RvInt32Const(1000000)
#define RV_TIME_NSECPERSEC RvInt32Const(1000000000)

/* Set easy to use 64 bit equivalents */
#define RV_TIME64_NSECPERUSEC RvInt64Const(1000)
#define RV_TIME64_NSECPERMSEC RvInt64Const(1000000)
#define RV_TIME64_NSECPERSEC RvInt64Const(1000000000)

#if defined(__cplusplus)
extern "C" {
#endif 

/* Prototypes and macros: See documentation blocks below for details. */
RVCOREAPI RvTime * RVCALLCONV RvTimeConstruct(RvTime *t, RvInt32 secs, RvInt32 nanosecs);
RVCOREAPI RvTime * RVCALLCONV RvTimeConstructFrom64(RvTime *t, RvInt64 nanosecs);
RvTime *RvTimeSubtract(RvTime *result, const RvTime *newtime, const RvTime *oldtime);
RvTime *RvTimeAdd(RvTime *result, const RvTime *time1, const RvTime *time2);
RvInt64 RvTimeConvertTo64(const RvTime *t);
#define RvTimeGetSecs(_t) ((_t)->sec)
#define RvTimeSetSecs(_t, _s) ((_t)->sec = (_s))
#define RvTimeGetNsecs(_t) ((_t)->nsec)
#define RvTimeSetNsecs(_t, _n) ((_t)->nsec = (_n))
#define RvTimeDestruct(_t)
#define RvTimeCopy(_t, _s) ((_t)->sec = (_s)->sec,(_t)->nsec = (_s)->nsec)

#if defined(RV_TEST_CODE)
void RvTimeTest(void);
#endif /* RV_TEST_CODE */

#if defined(__cplusplus)
}
#endif 
/*$
{function:
	{name: RvTimeConstruct}
	{superpackage: Time}
	{include: rvtime.h}
	{description:
		{p: Constructs a time.}
	}
	{proto: RvTime *RvTimeConstruct(RvTime *t, RvInt32 secs, RvInt32 nanosecs);}
	{params:
		{param: {n: t} {d: Pointer to time structure to construct.}}
		{param: {n: secs} {d: Initial value for seconds.}}
		{param: {n: nanosecs} {d: Initial value for nanoseconds. (0 to 999999999)}}
	}
	{returns: A pointer to the time structure or, if there is an error, NULL.}
}
$*/
/*$
{function:
	{name: RvTimeConstructFrom64}
	{superpackage: Time}
	{include: rvtime.h}
	{description:
		{p: Constructs a time from a 64 bit number of nanoseconds.}
	}
	{proto: RvTime *RvTimeConstructFrom64(RvTime *t, RvInt64 nanosecs);}
	{params:
		{param: {n: t} {d: Pointer to time structure to construct.}}
		{param: {n: nanosecs} {d: Initial time value in nanoseconds}}
	}
	{returns: A pointer to the time structure or, if there is an error, NULL.}
}
$*/
/*$
{function:
	{name: RvTimeSubtract}
	{superpackage: Time}
	{include: rvtime.h}
	{description:
		{p: Subracts two time values (result = newtime - oldtime).}
	}
	{proto: RvTime *RvTimeSubract(RvTime *result, const RvTime *newtime, const RvTime *oldtime);}
	{params:
		{param: {n: result} {d: Pointer to time structure where result will be stored.}}
		{param: {n: newtime} {d: Pointer to time structure to subract from. }}
		{param: {n: oldtime} {d: Pointer to time structure with value to subract.}}
	}
	{returns: A pointer to result or, if there is an error, NULL.}
	{notes:
		{note:  Absolute time values go negative before January 1, 1970 and
				wrap backwards in the year 1902.}
	}
}
$*/
/*$
{function:
	{name: RvTimeAdd}
	{superpackage: Time}
	{include: rvtime.h}
	{description:
		{p: Adds two time values (result = time1 + time2).}
	}
	{proto: RvTime *RvTimeAdd(RvTime *result, const RvTime *time1, const RvTime *time2);}
	{params:
		{param: {n: result} {d: Pointer to time structure where result will be stored.}}
		{param: {n: time1} {d: Pointer to first time.}}
		{param: {n: time2} {d: Pointer to second time structure.}}
	}
	{returns: A pointer to result or, if there is an error, NULL.}
	{notes:
		{note:  Absolute time values wrap in the year 2038.}
	}
}
$*/
/*$
{function:
	{name: RvTimeConvertTo64}
	{superpackage: Time}
	{include: rvtime.h}
	{description:
		{p: Converts a time value to a 64 bit value in nanoseconds.}
	}
	{proto: RvInt64 RvTimeConvertTo64(const RvTime *t);}
	{params:
		{param: {n: t} {d: Pointer to time structure to be converted.}}
	}
	{returns: A 64 bit nanoseconds value.}
}
$*/
/*$
{function:
	{name: RvTimeGetSecs}
	{superpackage: Time}
	{include: rvtime.h}
	{description:
		{p: Get the seconds value from a time structure.}
	}
	{proto: RvInt32 RvTimeGetSecs(RvTime *_t);}
	{params:
		{param: {n: _t} {d: Pointer to time structure to get information from.}}
	}
	{returns: Seconds.}
}
$*/
/*$
{function:
	{name: RvTimeSetSecs}
	{superpackage: Time}
	{include: rvtime.h}
	{description:
		{p: Sets the seconds value of a time structure.}
	}
	{proto: RvInt32 RvTimeSetSecs(RvTime *_t, RvInt32 _s);}
	{params:
		{param: {n: _t} {d: Pointer to time structure to set information in.}}
		{param: {n: _s} {d: Seconds.}}
	}
	{returns: Seconds value that was set.}
}
$*/
/*$
{function:
	{name: RvTimeGetNsecs}
	{superpackage: Time}
	{include: rvtime.h}
	{description:
		{p: Get the nanoseconds value from a time structure.}
	}
	{proto: RvInt32 RvTimeGetNsecs(RvTime *_t);}
	{params:
		{param: {n: _t} {d: Pointer to time structure to get information from.}}
	}
	{returns: Nanoseconds.}
}
$*/
/*$
{function:
	{name: RvTimeSetNsecs}
	{superpackage: Time}
	{include: rvtime.h}
	{description:
		{p: Sets the nanoseconds value of a time structure.}
	}
	{proto: RvInt32 RvTimeSetNsecs(RvTime *_t, RvInt32 _s);}
	{params:
		{param: {n: _t} {d: Pointer to time structure to set information in.}}
		{param: {n: _s} {d: Nanoseconds.}}
	}
	{returns: Nanoseconds value that was set.}
}
$*/
/*$
{function:
	{name: RvTimeDestruct}
	{superpackage: Time}
	{include: rvtime.h}
	{description:
		{p: Destructs a time object.}
	}
	{proto: void RvTimeDestruct(RvTime *_t);}
	{params:
		{param: {n: _t} {d: Pointer to time object to be destructed.}}
	}
}
$*/
/*$
{function:
	{name: RvTimeCopy}
	{superpackage: Time}
	{include: rvtime.h}
	{description:
		{p: Copies the value of one time structure to another.}
	}
	{proto: RvInt32 RvTimeCopy(RvTime *_t, RvTime *_s);}
	{params:
		{param: {n: _t} {d: Pointer to time structure to copy information to.}}
		{param: {n: _s} {d: Pointer to time structure to copy information from.}}
	}
	{returns: Nanoseconds value that was copied.}
}
$*/

#endif /* RV_TIME_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -