|
From: Rich C. <rc...@wi...> - 2011-11-17 21:15:02
|
On Thu, 17 Nov 2011 20:48:28 +0100
Bart Van Assche <bva...@ac...> wrote:
> On Thu, Nov 17, 2011 at 2:44 AM, Rich Coe <rc...@wi...> wrote:
> > How about ...
> >
> > #include <sys/mman.h>
> > #ifndef MREMAP_FIXED /* not defined by RHEL 4 */
> > #include <linux/mman.h>
> > #endif
>
> I'd rather prefer something like this:
>
> Index: memcheck/tests/x86-linux/scalar.c
> ===================================================================
> --- memcheck/tests/x86-linux/scalar.c (revision 12271)
> +++ memcheck/tests/x86-linux/scalar.c (working copy)
> @@ -5,8 +5,9 @@
> #include <unistd.h>
> #include <sched.h>
> #include <signal.h>
> -#include <linux/mman.h> // MREMAP_FIXED
> -
> +#ifndef MREMAP_FIXED
> +#define MREMAP_FIXED 2 // For RHEL 4
> +#endif
> // Here we are trying to trigger every syscall error (scalar errors and
> // memory errors) for every syscall. We do this by passing a lot of bogus
> // arguments, mostly 0 and 1 (often it's 1 because NULL ptr args often aren't
> @@ -23,7 +24,6 @@
> // The output has numbers like "3s 2m" for each syscall. "s" is short for
> // "scalar", ie. the argument itself is undefined. "m" is short for "memory",
> // ie. the argument points to memory which is unaddressable.
> -
> int main(void)
> {
> // uninitialised, but we know px[0] is 0x0
>
> Bart.
For user code calling mmap(), correct code will #include sys/mman.h.
So you need that. On RHEL.4, which is apparently non-unixy-compliant,
requires #include linux/mman.h.
I would not hard code MMREMAP in any case, which is what you have now.
Rich
--
Rich Coe rc...@wi...
|