This is the mail archive of the ecos-patches@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: [PATCH] add ftok() and getenv() functions to the synthetic target


Hi,

On Wednesday 26 October 2005 09:43, Andrew Lunn wrote:
> On Tue, Oct 25, 2005 at 10:13:15PM +0200, Alexander Neundorf wrote:
> > On Wednesday 19 October 2005 19:20, Alexander Neundorf wrote:
> > > Hi,
> > >
> > > the attached patch implements ftok() and getenv() for the synthetic
> > > target. This is quite useful, since often ipc keys are generated using
> > > ftok() and environment variables (getenv()).
> > > Both ftok() and getenv() are taken from FreeBSD. The FreeBSD getenv()
> > > is smaller and has no dependencies as compared to the eCos getenv()
> > > (which uses strlen() and strncmp()).
>
> I don't see the point in the getenv() code. Why not just
>
> environ = cyg_hal_sys_environ;
>
> and then use getenv()?

Ok, that's a good idea, but it has an issue.
In my case I need the DISPLAY variable in my eCos application. getenv() lives 
in CYGPKG_LIBC_STDLIB. But the actual application doesn't need 
CYGPKG_LIBC_STDLIB, so I would have to add a package when I compile it for 
the synthetic target, while I don't need this package when compiling for the 
real target. This would mean that the configuration and "environment" for the 
same application would differ only because some utility function in the 
synthetic target needs to access the value of a environment variable from the 
host environment. I don't think this is a good idea.
And as you said, this is synth., so the size increase through the additional 
cyg_hal_sys_getenv() doesn't matter ;-)

...
> As for ftok() i don't see much point in using the FreeBSD version. The
> Linux man page tells you what it does, so why not just re-implement it
> and save us a big license header.

That's all what the ftok man page on my system (slackware) says:
"Typically, a best effort attempt combines the given proj_id byte, the lower 
16 bits of the i-node number, and the lower 8 bits of the device number into 
a 32-bit result."

So I had to look for an example implementation, couldn't use the one from 
glibc (LGPL), so I ended up with the BSD version.

Bye
Alex
-- 
Work: alexander.neundorf@jenoptik.com - http://www.jenoptik-los.de
Home: neundorf@kde.org                - http://www.kde.org
      alex@neundorf.net               - http://www.neundorf.net


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