Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
116 user(s) are online (89 user(s) are browsing Forums)

Members: 1
Guests: 115

Hans, more...

Support us!

Headlines

 
  Register To Post  

OS4.1's Newlib & timezone.library
Quite a regular
Quite a regular


See User information
Does newlib is taking timezone.library into account when dealing with time, timezone and DST ? I ask because it does not seems to me, but I may have done something wrong...

Back to a quiet home... At last
Go to top
Re: OS4.1's Newlib & timezone.library
Just popping in
Just popping in


See User information
@abalaban

I doubt this. newlib.library is a kickstart module while timezone.library is a "normal" disk based library. Hence newlib.library exists from the absolute beginning of the system boot process, while timezone.library will be loaded aeons (in terms of computer time scale) later.

timezone.library might come into play if it patches newlib.library, but again, I doubt this.

Go to top
Re: OS4.1's Newlib & timezone.library
Quite a regular
Quite a regular


See User information
@tboeckel

What I'm trying to know is if newlib's time and timezone functions (time(), , localtime(), gmttime(), strftime() etc.) are aware/make use of timezone.library or not. My current problem is that I have my OS 4.1 system setup as using Paris timezone, i.e. UTC+1, or CET, but we are in summer and DST is currently in effect which take us to UTC+2 or CEST. Now using newlib functions it seems like I'm still at CET which give me crong results.

I'm aware newlib is a kickstart module while timezone.library is not but nothing tells me that, like some Exec functions with Locale.library, newlib implementation does not make use of timezone.library once loaded...
And if it's not the case I'm afraid then that we have some serious bugs in every ported softs that are computing times using newlib's functions.

Back to a quiet home... At last
Go to top
Re: OS4.1's Newlib & timezone.library
Just can't stay away
Just can't stay away


See User information
@abalaban
A Hex search in newlib.library shows "timezone.library" there, which indicates that newlib might use that library. Have you compared the results of the C time functions in newlib to the same functions in you compile with clib2 instead?

Go to top
Re: OS4.1's Newlib & timezone.library
Just popping in
Just popping in


See User information
@abalaban

Oh, it seems newlib.library indeed does use timezone.library:

52.12 (21.1.2007)
- Fixed a bug in opening timezone.library, it could get expunged and
newlib.library crashed calling ITimezone functions.

52.11 (19.1.2007)
- Added a workaround for the timezone.library problem.

52.10 (18.1.2007)
- More changes in the math functions, added gamma(), gammaf(), lgamma()
and lgammaf().
- Time functions now use timezone.library to get the UTC offset?and
dst flag.

If that doesn't work properly you better contact J?rg Stohmayer.

Go to top
Re: OS4.1's Newlib & timezone.library
Just can't stay away
Just can't stay away


See User information
@abalaban

#REXX:DepsTrack.rexx sys:Kickstart/newlib.library.kmod
depstrack V0.3B por megacz@usa.com - tracks dependencies in binaries

/// analyzing 'sys:Kickstart/newlib.library.kmod' (517856 bytes)...
/// showing dependencies...
=== newlib.library
=== dos.library
=== elf.library
=== timezone.library
=== locale.library
=== bsdsocket.library
=== usergroup.library
=== timer.device
/// found 8 dependencies in 0.86 secs.


So it seems newlib uses timezone.

Go to top
Re: OS4.1's Newlib & timezone.library
Quite a regular
Quite a regular


See User information
@tboeckel

Okay I made some experiment, consider the following sample
#include <stdio.h>
#include <time.h>
#include <locale.h>

int main(void)
{
   
time_t now time(NULL);
   
char localstr[2048], gmtstr[2048];
   
struct tm localtmgmtm;

   
setlocale(LC_ALL"fr");

   
localtime_r(&now, &localtm);
   
gmtime_r(&now, &gmtm);

    
strftime(localstr2040"%A %e %B %Y %X, (%Z %z)", &localtm);
    
strftime(gmtstr2040"%A %e %B %Y %X, (%Z %z)", &gmtm);

   
printf("localtime : %s (tm offset %ld)\n"
          "utc : %s (tm offset %ld)\n"
,
          
localstrlocaltm.tm_gmtoffgmtstrgmtm.tm_gmtoff);

   return 
0;
}

now this output
Nouvelle t?che Shell 11
11.Langages
:tempodate
Vendredi 21
/08/2009 11h10
11.Langages
:tempotestime 
localtime 
Friday 21 August 2009 11:10:35, (CET +0200) (tm offset -120)
utc Friday 21 August 2009 09:10:35, (CEST +0200) (tm offset 0)


Now I'm not an expert of ANSI locale and timezone but in this small sample there things that annoy me :
1) strftime on the localtime give a timezone (%Z) of CET while we are currently at CEST and the offset (%z) and tm_gmtoff are correctly set to 2 hours
2) despite I used %A and %B to get locale's name for weekday and month I got english one no matter if I use setlocale() or not and whatever value I put for it (looking at the specs on opengroup.org it passing an empty string should have used the default system's locale)
3) strange (but opengroup.org says the result is undefined) strftime returns the correct timezone (CEST) when passed an UTC time...

Back to a quiet home... At last
Go to top
Re: OS4.1's Newlib & timezone.library
Just can't stay away
Just can't stay away


See User information
@abalaban
I tried to compile your example with clib2 but it fails because the members
tm_gmtoff & tm_zone are not defined as part of the tm structure. The GNU WEB site lists those members as extensions. If you google tm_gmtoff, you will see lots of complaints from programmers having problems compiling programs referencing those extensions. Maybe the latest C compiler standards include those members but I wouldn't know where to find that out.
The definitions I found for those members seem to leave the definition of tm_zone for localtime open to interpretation. Maybe the newlib programmers interpret it to mean "the name of the timezone" and not the "UTC timezone designation for the timezone when daylight savings is in effect". One could argue that your problem might be a matter of interpretation rather than a bug.

Go to top
Re: OS4.1's Newlib & timezone.library
Quite a regular
Quite a regular


See User information
@xenic

yes but then it's an interpretation that is not compliant with other systems having those extensions. In fact I discovered the problem while running a testcase of wxWidgets (which I'm porting to AOS4) and this part of the code is used on any other platform supported by wxWidgets (Windows, Linux, MacOS to name the major)

Back to a quiet home... At last
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 2 ( 0 members and 2 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project