This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ecos and gettimeofday()


On Fri, Oct 14, 2005 at 09:30:56PM +0200, Alexander Neundorf wrote:
> Hi,
> 
> On Thursday 13 October 2005 19:12, Andrew Lunn wrote:
> > Jifl message made is clear that the implementation does not belong in
> > the header file. libc is the wrong as well. The correct place would be
> > posix since this is a posix function. It might be possible to persuade
> > me it could go in a package of its own, but i'm not sure about that.
> 
> Ok, attached is a new version of the patch (still not meant for inclusion). 
> Now gettimeofday() is implemented in posix/src/gettimeofday.cxx. Additionally 
> I modified posix.cdl so that gettimeofday.cxx can be compiled separately 
> without the rest of the posix package. The rest of the posix package is now 
> combined in a CYGPKG_POSIX_BASIC, which is enabled by default, but can be 
> disabled now too. Probably the name is not the best.
> What do you think ?

I think this is very ugly....
 
Did you even read posix.cdl?

The POSIX package is already split onto:
1) A generic part for mqueues, mutex and misc function like guid().
2) Scheduling Functions
3) Threads
4) Clocks
5) Timers
6) Semaphores
7) Signals

1) is not optional. Only a very small part goes into libextra.a which
the linker cannot throw away. The rest will only get pulled in when
needed.  It also looks like it would be easy to move mqueues out of
the generic part and into a package of its own. I also think mutex
could be moved, but it is not as obvious from looking at the
code. There might be some dependancies hiding in there i could not see
with just 30s of browsing the code.

All the other parts can be disabled using CDL options.  So your hack
is pretty much redundant.

I suggest you add gettimeofday() to the end of time.cxx.

> 
> > Also your implementation is not so great. Look at Nick's in the ppp
> > code. Nick's is less arithmetic and less likely to cause an overflow.
> 
> From net/ppp/current/src/sys-ecos.c:
> 
> int gettimeofday(struct timeval *tv, struct timezone *tz)
> {
>     cyg_tick_count_t time = cyg_current_time();
>     tv->tv_sec = time/CYGNUM_HAL_RTC_DENOMINATOR;
>     tv->tv_usec = (time%CYGNUM_HAL_RTC_DENOMINATOR)*10000;
>     return 0;
> }
> 
> IMHO according to 
> http://sources.redhat.com/ecos/docs-latest/ref/hal-clocks-and-timers.html 
> also this version is not completely correct:

I will let Nick comment on this. 

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]