autoconf
[Top][All Lists]
Advanced

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

Re: detecting mmap?


From: Schleicher Ralph (LLI)
Subject: Re: detecting mmap?
Date: Thu, 18 Jul 2002 13:51:37 +0200

Donn Terry <address@hidden> writes:

> The current code to detect if mmap() is present and operational is
> excessively draconian, in my opinion.

The GNU coding standards has a section about how to use mmap.
Following these guidelines always works for me.  For short: use
AC_CHECK_FUNCS([mmap]) instead of AC_FUNC_MMAP.  Then write, for
example,

    void *p;

  #if HAVE_MMAP && defined (PROT_*) && defined (MAP_*)

    p = mmap (NULL, n, PROT_*, MAP_*, fd, 0);
    if (p != NULL)
      return p;

  #endif

    /* mmap() doesn't work, use malloc().  */
    p = malloc (n);
    if (p != NULL && read (fd, p, n) != n)
      {
        free (p);
        p = NULL;
      }

    return p;

-- 
Ralph




reply via email to

[Prev in Thread] Current Thread [Next in Thread]