Files
m241Neelima/components/ip_net2-6.9/ipcom/port/src/ipcom_times.c
T
2026-07-30 11:19:44 +05:30

134 lines
3.8 KiB
C

/*
******************************************************************************
* SOURCE FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_RCPL8_2024030303 $ $RCSfile: ipcom_times.c,v $ $Revision: 1.3.172.1 $
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_times.c,v $
* $Author: jren $ $Date: 2023-10-20 05:48:41 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Lennart Bang <lob@interpeak.se>
******************************************************************************
*/
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
#include "ipcom_config.h"
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#define IPCOM_USE_CLIB_PROTO
#include "ipcom_clib.h"
#include "ipcom_time.h"
/*
****************************************************************************
* 4 EXTERN PROTOTYPES
****************************************************************************
*/
/*
****************************************************************************
* 5 DEFINES
****************************************************************************
*/
/*
****************************************************************************
* 6 TYPES
****************************************************************************
*/
/*
****************************************************************************
* 7 LOCAL PROTOTYPES
****************************************************************************
*/
/*
****************************************************************************
* 8 DATA
****************************************************************************
*/
/*
****************************************************************************
* 9 LOCAL FUNCTIONS
****************************************************************************
*/
/*
****************************************************************************
* 10 PUBLIC FUNCTIONS
****************************************************************************
*/
/*
*===========================================================================
* ipcom_times
*===========================================================================
* Description:
* Parameters:
* Returns:
*
*/
#if defined(IPCOM_TIMES) && IPCOM_TIMES == 1
IP_PUBLIC Ip_clock_t
ipcom_times(struct Ip_tms *buf)
{
struct Ip_timeval tv;
Ip_time_t now;
static Ip_time_t start = 0;
ipcom_microtime(&tv);
if(start == 0)
start = tv.tv_sec * 1000 + tv.tv_usec / 1000;
now = tv.tv_sec * 1000 + tv.tv_usec / 1000;
/* Fix for clock being set back in time. */
if(start > now)
start = now;
/*!! NOTE: Nonsense values. */
if (buf != IP_NULL)
{
buf->tms_utime = now;
buf->tms_stime = now;
buf->tms_cutime = now;
buf->tms_cstime = now;
}
return (Ip_clock_t)(now - start); /* milliseconds since system start. */
}
#else
int ipcom_times_empty_file;
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/