[pypy-dev] Re: [pypy-svn] r18792 - in pypy/dist/pypy/translator/c: . src test
Armin Rigo
arigo at tunes.org
Sun Oct 23 21:23:39 CEST 2005
Hi Christian,
On Sun, Oct 23, 2005 at 08:12:28PM +0200, Christian Tismer wrote:
> As a result, I created a DIR structure that holds the windows handle
> plus the search structure,and it acts as the dirent structure as well.
> The opendir() allocates and returns this structure and sets a flag.
> readdir() checks the flag on first call and takes the already existing
> resultfrom the structure. Otherwise it behaves as expected.
This is a nice enough approach. I suppose that we could expose
different interfaces through rpython/extfunctable depending on the OS,
but it looks like it's more trouble than it's worth.
> And I'm especially unhappy that I needed to use malloc. But to avoid
> this, the opendir() would need to have an interface to pass some
> memory in, you would need a call to obtain its needed size, ...
There is a way to let the memory be handled automatically, but again it
would need two versions of the functions in rpython/extfunctable and
rpython/module/ll_os.py so let's not bother here. [ This is what
Thread.LockType uses: a lock is a GcStruct with a single opaque field,
whose type is only declared in C. The RTyper generates
malloc(<GcStruct>), GenC uses refcounting or boehm GC as usual on the
structure, but manipulation of the opaque field are done only by C code.
There is even no needed to obtain its size from higher levels, because
we can generate an operation 'malloc(<GcStruct>)' and let the C code
figure out the size with a sizeof() -- which is what occurs for all
GcStructs, btw. ]
A bientot,
Armin.
More information about the Pypy-dev
mailing list