[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mmap()-like functionality in Win32



Bjarke Hammersholt Roune schrieb:
> 
> Peter Burns is indeed correct: Win32 *does* implement mmap()-like behavior.

Good.

> Well, Christian, it seems that everything is a-ok on the Win32 portability
> issues of using mmap(). I think I will need some Win32-specific variables
> inserted in some structs:

Theoretically no problem - but in practice it is. You know that Iīm
currently applying some rather big changes to PFile and Iīd prefer to
have one set of major changes finished before I apply the next one.
Ok, letīs see. I donīt have much time (my first - and hardest - exam
this semester is already on tuesday), but Iīll try to build an
intermediate PFile version, with the VFS system in place but without Pak
writing support. You could take this version, fiddle around with it, add
the Win32 specific things, debug it (grin) and when I have the next
revision working (i.e. with PakFile writing + ppfMkDir () etc) we merge
the versions.

Also donīt bother too much about the mmapping now - Iīm still not
completely sure whether it really would be good in all situations.
Thereīs still some testing to do (try opening a BIG file (larger than
your system memory), access (1) random locations, (2) random groups of
(locations close to each other) (bracing to illustrate "operator
precedence" ;) and perhaps some larger linear reading. Do this once via
stdio and once with a mmapped file (the entie file), preferably while
some other big program is running in the background) and measure the
performance difference).

> This means you (Christian Reiniger) will most likely (if I do not find some
> other way to do it)  have to do a bit of #ifdef'ing for the symbols
> _PP_POSIX and _PP_WIN32, calling different functions based on which is
> defined (don't make it so that the absense of the one automaticly makes the
> code look as if the other is not absent, though, that would make porting to
> yet another platform harder).

Well, having one function
void *ppf_MMap (const char *filename, int flags); 
that encapsulates both POSIX and Win32 versions would be fine.

> btw, I would appreciate it if you could could change this specific bit of
> PenguinPlay.h:
> 
> #ifdef HAVE_UNISTD_H
> #  define _PP_POSIX
> #  include <unistd.h>
> #else
> #  error "POSIX functionality currently needed"
> #endif
> 
> to this:
> 
> #ifdef HAVE_UNISTD_H
> #  define _PP_POSIX
> #  include <unistd.h>
> #elif defined(WIN32)
> #  define _PP_WIN32
> #else
> #  error "POSIX or Win32 functionality currently needed"
> #endif

Not like that. Two seperate #ifdefs are better (because POSIX and Win32
donīt 100% overlap).
And - letīs do it as I described above. Iīll add no Win32 things to the
main code yet - add it to your personal copy for now and weīll merge it
when my current code update is done (which will be before my holiday
unless something serious happens).

	Christian