This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Problem in cyg_io_compare?
davidw@dedasys.com (David N. Welton) writes:
> If the two strings are equal, cyg_io_compare returns true, but the
> 'name' pointer in my lookup function is garbage because *ptr is set
> off the end of n1 in the compare function. This patch fixes that by
> storing the original location of 'n1' to later put in '*ptr'.
*ptr should end up pointing to the residue of n1 after the match with
n2. In the case where both are equal, then *ptr ends up pointing to
the \0 at the end of n1. Your change makes *ptr point back at the
beginning of n1, which is not what the function is meant to do.
Now, I may be misreading both versions of the function here. But the
current version seems OK to me. (Although I am still not sure what
that if(*n1)... in the middle is doing.)
>
> I think that in any case, returning a bogus address should be avoided
> in one way or another.
>
> On another topic... how does one calculate ticks per second?
>
> # Real-time clock constants.
> # The RTC period is based on the clock input
> # to the 8254, which is 1193180 Hz.
> # CYGNUM_HAL_RTC_PERIOD is set for 100 ticks
> # per second.
>
> Is it just a coincidence that CYGNUM_HAL_RTC_DENOMINATOR is 100? My
> .ecc file has:
No, numerator/denominator == ns per tick. Since the numerator is 10^9
then the denominator ends up being the clock frequency. We keep them
like this, rather than eliminating common factors, to make this
relationship easier to work with.
>
> cdl_option CYGNUM_HAL_RTC_PERIOD {
> # Calculated value: 11932
> # Flavor: data
> # Current_value: 11932
> };
>
> And of course 1193180 / 11932 gives me about the right number, but the
> top number is a 'magic number' and not to my knowledge defined
> anywhere.
Sorry, I'm lost, which is the magic number here?
--
Nick Garnett eCos Kernel Architect
http://www.ecoscentric.com The eCos and RedBoot experts
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss