Failure of mmap() is signaled by MAP_FAIL (Posix), but in some platforms it is not defined and specified as -1

This commit is contained in:
Juan Jose Garcia Ripoll 2009-01-27 21:55:15 +01:00
parent 92c4454ece
commit a40ed5054c

View file

@ -34,6 +34,9 @@
#endif
#ifdef ECL_USE_MPROTECT
# include <sys/mman.h>
# ifndef MAP_FAIL
# define MAP_FAIL -1
# endif
#endif
#include <stdio.h>
#include <stdlib.h>
@ -212,8 +215,8 @@ _ecl_alloc_env()
cl_env_ptr output;
#if defined(ECL_USE_MPROTECT)
output = mmap(0, sizeof(*output), PROT_READ | PROT_WRITE,
MAP_ANON | MAP_PRIVATE, 0, 0);
if (output < 0)
MAP_ANON | MAP_PRIVATE, -1, 0);
if (output == MAP_FAIL)
ecl_internal_error("Unable to allocate environment structure.");
#else
output = ecl_alloc(sizeof(*output));