[Python-Dev] Re: Almost insignificant patch for mmapmodule

Lorenzo M. Catucci lorenzo@sancho.ccd.uniroma2.it
Sun, 18 Jun 2000 09:39:55 +0200 (CEST)


On Sun, 18 Jun 2000, Andrew Kuchling wrote:

AK> On Sat, Jun 17, 2000 at 04:29:14PM +0200, Lorenzo M. Catucci wrote:
AK> >therefore, here is the change: if we are compiling for linux, define
AK> >_GNU_SOURCE before including mman.h, and all is done. It seems the
AK>=20
AK> Hmm... IMHO this points out a bug; if MREMAP_MAYMOVE is not present,
AK> that doesn't imply that mremap() doesn't work at all; instead, a
AK> resize may fail if the mapping would have to be moved to a different
AK> virtual address.  Quoting from the Linux man page:
AK>=20
AK>        MREMAP_MAYMOVE
AK>               indicates  if  the operation should fail, or change
AK>               the virtual address if the resize cannot be done at
AK>               the current virtual address.
AK>=20
AK> I think the correct fix is to simply specify MREMAP_MAYMOVE if it's
AK> defined, but still support attempting to resize. Possibly the
AK> configure script should also check for mremap()'s existence.
AK>=20

I think I've been too dense... Here I see two problems: on one hand, from
what I have understood of python's object, it's much better if the c
pointers are movable in VM on the remap, and the MAYMOVE flag is only
defined in mman.h if _GNU_SOURCE is; on the other hand, we only know
about linux mremap semantics: for what I see in linix mremap(2)

"""
CONFORMING TO
       This  call  is  Linux-specific,  and should not be used in
       programs intended to be portable.   4.2BSD  had  a  (never
       actually  implemented) mremap(2) call with completely dif=AD
       ferent semantics.
"""

Therefore, I think that really checking for __linux__ and using the
MAYMOVE flag, which is thefined there, is going towards the right way. If
someone else comes out with another kernel supporting a mremap syscall[1],
I think we'll be able to add proper support afterwards. As for the
configure script, on linux we have both mremap and MAYMOVE; if you go to
the <a href=3D"http://www.gnu.org/software/libc/all-M.html">Extended UNIX A=
BI, M*
</a> Page,=20

you'll find:

=09GNU Unix98 Unix95 POSIX ISO C SVID 3 4.3BSD XPG
mremap   X

It seems only the systems supported by GNU libc-2 (only linux systems,
then) support mremap...

Have a nice time.


lmc


* Just tried searching for mremap on=20
http://www.FreeBSD.org/cgi/man.cgi?query=3Dmmap
and looked around the various BSD derivatives whose man pages are
available there.=20

+-------------------------+----------------------------------------------+
|   Lorenzo M.  Catucci   | Centro di Calcolo e Documentazione           |
| catucci@ccd.uniroma2.it | Universit=E0 degli Studi di Roma "Tor Vergata" =
|
|                         | Via O. Raimondo 18 ** I-00173 ROMA  ** ITALY |
|  Tel. +39 06 7259 2255  | Fax. +39 06 7259 2125                        |
+-------------------------+----------------------------------------------+