The basic design idea of PDCLib is to implement as much of the language standard as possible in a completely generic manner (./functions). (Should you desire an implementation optimized to a specific platform, just add the replacement implementation to ./platform/<your_platform>/functions/...) Where you absolutely, positively cannot achieve something without support from the operating system, I added a "wrapper" function that "wraps" actual system calls in a somewhat-generic "PDCLib wrapper" (in ./platform/example/functions/_PDCLIB/) -- so you might be able to implement the innards of that wrapper on more than one target platform without having to touch the generic code.kuraga wrote:One more question about memory allocation. (Note: I'm a beginner here and I might say something wrong). We need to implement _sbrk function only in Newlib (and PDCLib's retrace branch, as I see) for memory allocation. In dlmalloc we need sys/mman.h, etc. Question: is it just design (which could be another) or is it involved with MMU/MMU-less?
Lacking a cross-platform way to get memory from the OS, I decided on a wrapper ( _PDCLIB_allocpages() ) that allocates n "pages" of memory in whatever way the OS supports. (For Unixes, sbrk() / brk() were what I opted for; you could probably use mmap() just as well.) I figured that would be "good enough". The malloc() / free() implementation based on this wrapper is, however, very very basic.
I had been looking at integrating dlmalloc(), which is Public Domain, well-tested, and offers pretty good performance. Owen actually did that integration. It ( dlmalloc() ) just happens to require different system calls to function, but I found the way Owen did the integration to be a bit heavy-handed. Getting dlmalloc() back into the "retrace" branch would probably be my next action, because the current malloc() / free() implementation is shamefully primitive.
Errr.... I don't get your meaning?P.S. So, default should be merged into retrace or retrace into default?
"default" is my baseline plus Owen's work, "retrace" is my baseline plus additional work I added this year, most of it based on Owen's work, some genuinely mine.
"retrace" is closer to the "shape" I wanted PDCLib to have, but not yet as feature-rich as the "default" branch. I am working at closing the gap, by adding features to "retrace" that might or might not be already present in "default" but which are, in any case, following my idea of internal architecture of the library.
Should I reach the point where "retrace" has all the features of "default" (possibly plus some), I figure the "default" branch will be retired.