On Tue, Aug 17, 2010 at 5:42 PM, David Marlin wrote:
> Mike Frysinger wrote:
>> On Tue, Aug 17, 2010 at 2:34 PM, David Marlin wrote:
>>> 'lchown02.c' does not build properly due to calls to mmap and
>>> get_high_address (which references sbrk) when UCLINUX=1 is defined.
>>
>> you'll need to clarify. it builds fine for me, it just may not run
>> correctly due to the assumptions of memory placement.
>
> Thank you for the feedback. I'm new to uClinux, so I'm only going on what
> I've read, but my understanding is that 'sbrk' is not supported in uClinux.
it depends on how you use it. sbrk(0) should always work since you're
only querying the current size. sbrk(1+) might work depending on the
current memory layout, but it isnt reliable, so it's recommended
people dont use it when possible on nommu. technically speaking, it
can even fail under mmu systems, it's just highly unlikely with newly
started processes.
the lib/get_high_address.c usage is valid since it does sbrk(0), but
overall the function is useless since it is assuming that a few pages
after the end of the sbrk() region is unallocated memory. on nommu
systems, it could easily be valid (either the same process or a
different one or the kernel).
so on nommu/linux, this function should be avoided due to its design
flaws, not because any of the unctions it calls do not work.
> My information may be a bit dated, so a newer (better) reference would be
> welcome.
you will often find nommu stuff undocumented. my experience is that
the people who know arent interested in writing documentation (why
should they when they already know the answer !?), and there arent
that many people who know :P. i dont mind writing documentation
though (due to my personal experience of constantly hitting this
problem and making my stomach churn), so feel free to ask questions.
> Much of the syscalls test code that is "#ifdef'd" out for UCLINUX=1 involves
> skipping references (directly or indirectly) to sbrk. get_high_address is
> one of those references, where it directly calls sbrk:
>
> char *get_high_address(void)
> {
> return (char *)sbrk(0) + (4 * getpagesize());
> }
>
> Most of the testcases skip the call to get_high_address when UCLINUX=1, so I
> was just following their example.
i like to look forward and start down a better path rather than
continue to hedge overgrown crap ;)
-mike
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list