[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Patch for the getpagesize module
From: |
Bruno Haible |
Subject: |
Re: Patch for the getpagesize module |
Date: |
Tue, 4 Dec 2007 09:45:02 +0100 |
User-agent: |
KMail/1.5.4 |
Martin Lambers wrote:
> It seems to be only in libgcc.a, both in MinGW-5.1.3+MSYS and
> Debian-crosscompiled (version 3.4.5.20060117.1.dfsg-2 from etch).
Indeed! The libgcc.a contains a file _trampoline.o that was compiled from
this piece of gcc-3.4.4/gcc/libgcc2.c:
------------------------------------------------------------------------------
long
getpagesize (void)
{
#ifdef _ALPHA_
return 8192;
#else
return 4096;
#endif
}
#ifdef __i386__
extern int VirtualProtect (char *, int, int, int *) __attribute__((stdcall));
#endif
int
mprotect (char *addr, int len, int prot)
{
int np, op;
if (prot == 7)
np = 0x40;
else if (prot == 5)
np = 0x20;
else if (prot == 4)
np = 0x10;
else if (prot == 3)
np = 0x04;
else if (prot == 1)
np = 0x02;
else if (prot == 0)
np = 0x01;
if (VirtualProtect (addr, len, np, &op))
return 0;
else
return -1;
}
------------------------------------------------------------------------------
> How should this be handled?
I would not reuse this getpagesize() function since there may be situations
where the page size is different (x86_64, no?).
I would not reuse this mprotect() function since it does not set errno
upon failure.
> > The implementation that you gave in your previous patch
> >
> > #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
> > SYSTEM_INFO system_info;
> > GetSystemInfo (&system_info);
> > return system_info.dwPageSize;
> >
> > is the same as the one used in GNU clisp for 10 years, so you can assume
> > that it works. (And its value on 32-bit x86 platforms is 0x1000.)
> >
> > I would therefore find it reasonable to create a lib/getpagesize.c file
> > just for this case of native Windows. What do you think?
>
> Yes, but I'm not sure how the conditional compilation of this file
> should be handled.
> Should getpagesize.m4 call AC_LIBOBJ([getpagesize]) only on W32?
Yes. There is normally no point in compiling an empty object file.
But you can put a prominent notice in the getpagesize.c file that it
provides the function only for native Win32 platforms, and not for all
platforms that lack the function.
Can you provide the patch, please? (My working environment is a bit disturbed
these days, sorry.) Let me only document the issue about mprotect.
Bruno
2007-12-03 Bruno Haible <address@hidden>
* doc/functions/mprotect.texi: Mention the mingw problem.
*** doc/functions/mprotect.texi.orig 2007-12-03 22:43:14.000000000 +0100
--- doc/functions/mprotect.texi 2007-12-03 22:32:54.000000000 +0100
***************
*** 16,21 ****
--- 16,24 ----
This function is missing on some platforms:
mingw, BeOS.
@item
+ This function does not set @code{errno} on some platforms:
+ mingw.
+ @item
On AIX, it is not possible to use @code{mprotect} on memory regions allocated
with @code{malloc}.
@end itemize
Re: Patch for the getpagesize module, Jim Meyering, 2007/12/03