Problem with time function- Base time reference.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As you have ascertained any recent time translated into milliseconds
since 0:00 January 1 1979 UTC cannot be stored in a 32-bit integer. As
you can imagine this is why the pj_time_val is stored into two 32-bit
integers. Whether or not you should store it in a pj_time_val cannot be
determined without knowing how you are going to use it. Using
pj_time_val is convenient since there are lots of library functions for
dealing with time_t. If you're doing lots of arithmetic between time
values that require ms precision then in your particular case using
int64_t (supposing your platform supports it) might be more convenient.

One point here may be that the macro in question is useless if in all
pjtools builds the pj_time_val has 32-bit integers inside it since it
will always overflow.

On 6/20/11 3:04 PM, Jorge wrote:
> Thank you for your answer.
>
> The problem here is that I need msec so I am using milliseconds
> through this macro :
>
> #define PJ_TIME_VAL_MSEC(t)    ((t).sec * 1000 + (t).msec)         
> the output size is 32 bits so  I am losing some resolution.
>
> **31 536 000** seconds so in msec 31 536 000 000 that is more that the
> maximum value that can be stored inside a 32 bit variable.
>
> 2^32 = 4 294 967 296
>
> Is it possible to store this value inside a 32 bits variable or should
> I use a pj_time_val variable?
>
> Regards
>
> Jorge
>
> 2011/6/17 Jens Jorgensen <jbj1 at ultraemail.net
> <mailto:jbj1 at ultraemail.net>>
>
>     Generally speaking such values in seconds are in seconds since The
>     Epoch (Jan 1 1970 GMT).
>
>     On 6/17/11 10:24 PM, Jorge wrote:
>>     Hello:
>>
>>     I would like to delay a process so I am using this function to
>>     calculate the delay I should use pj_gettimeofday. I have read the
>>     documentation :
>>
>>     pj_status_t
>>     <http://www.pjsip.org/pjlib/docs/html/group__PJ__BASIC.htm#gab43ba3167bd2a2ab4580509dbf79200e>
>>     pj_gettimeofday 	( 	pj_time_val
>>     <http://www.pjsip.org/pjlib/docs/html/structpj__time__val.htm>
>>     *  	/tv/ 	 )  	
>>
>>     Get current time of day in local representation.
>>
>>     *Parameters:*
>>
>>         	/tv/  	Variable to store the result.
>>
>>     *Returns:*
>>         zero if successful. 
>>
>>
>>     But what I don?t know which is the base time that this function
>>     is taken as a reference. Because if it is a day I will have a
>>     problem at 00:00 h at night.
>>
>>     Could you say to me if it is taken as a reference an hour
>>     reference, a day reference or a year reference?
>>
>>     Regards
>>
>>     Jorge
>>
>>
>>     _______________________________________________
>>     Visit our blog: http://blog.pjsip.org
>>
>>     pjsip mailing list
>>     pjsip at lists.pjsip.org <mailto:pjsip at lists.pjsip.org>
>>     http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>
>
>     -- 
>     Jens B. Jorgensen
>     jbj1 at ultraemail.net <mailto:jbj1 at ultraemail.net>
>
>
>     _______________________________________________
>     Visit our blog: http://blog.pjsip.org
>
>     pjsip mailing list
>     pjsip at lists.pjsip.org <mailto:pjsip at lists.pjsip.org>
>     http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>
>
>
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
>
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org


-- 
Jens B. Jorgensen
jbj1 at ultraemail.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20110620/72687c58/attachment.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux