This is the mail archive of the ecos-discuss@sources.redhat.com 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: how cyg_mtocl(x) and cyg_cltom(x) work?


On Tue, 2002-12-31 at 01:53, 张 亮 wrote:
> 
> Hello, Mr. gthomas and everyone,
>      I really do not know the principle of function mtocl(x)and cltom(x).
> :
> int
> cyg_mtocl(u_long x)
> {
>     int res;
>     res = (((u_long)(x) - (u_long)mbutl) >> MCLSHIFT);
>     return res;
> }
> 
> struct mbuf *
> cyg_cltom(u_long x)
> {
>     struct mbuf *res;
>     res = (struct mbuf *)((caddr_t)((u_long)mbutl + ((u_long)(x) << 
> MCLSHIFT)));
>     return res;
> }
> 
> here,mbutl is a pointer to pointer to cluster memory pool,I really do not 
> know
>           (((u_long)(x) - (u_long)mbutl) >> MCLSHIFT and 
>          ((caddr_t)((u_long)mbutl + ((u_long)(x) << MCLSHIFT
>            mean what?
>           because mbuf memory pool and cluster memory pool are two 
> deffirent memory pool,so  add address or sub address means what?
> SOS,please help me!

'mbutl' points to the cluster area - it has nothing to do with
'mbuf's.  These expression mtocl()  takes a cluster address and
map them onto an index, kind if like an array index.  These
index values are then used for some small static tables which
are used to indicate when clusters are in use.

-- 
------------------------------------------------------------
Gary Thomas                 |
MLB Associates              |  Consulting for the
+1 (970) 229-1963           |    Embedded world
http://www.mlbassoc.com/    |
email: <gary@mlbassoc.com>  |
gpg: http://www.chez-thomas.org/gary/gpg_key.asc
------------------------------------------------------------


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


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