/* confdefs.h. */ E "bufferpool" #define PACKAGE_TARNAME "bufferpool" #define PACKAGE_VERSION "0.0.1" #define PACKAGE_STRING "bufferpool 0.0.1" #define PACKAGE_BUGREPORT "" #define PACKAGE "bufferpool" #define VERSION "0.0.1" #define HAVE_DLFCN_H 1 #define TIME_WITH_SYS_TIME 1 #define HAVE_SYS_TIME_H 1 #define HAVE_ERRNO_H 1 #define WORDS_BIGENDIAN 1 #define HAVE_SYS_ERRNO_H 1 #define HAVE_DIRENT_H 1 #define HAVE_FCNTL_H 1 #define HAVE_MALLOC_H 1 #define HAVE_SYS_TIME_H 1 #define size_t unsigned int #define HAVE_ERRNO_H 1 #define pid_t int #define TIME_WITH_SYS_TIME 1 #define HAVE_SYS_ERRNO_H 1 #define HAVE_FCNTL_H 1 #define HAVE_GETPAGESIZE 1 #define HAVE_MMAP 1 #define HAVE_MALLOC_H 1 #define size_t unsigned int #define pid_t int #ifndef __cplusplus #define inline __inline__ #endif #define HAVE_STRDUP 1 /* end confdefs.h. */ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif /* malloc might have been renamed as rpl_malloc. */ #undef malloc /* Thanks to Mike Haertel and Jim Avera for this test. Here is a matrix of mmap possibilities: mmap private not fixed mmap private fixed at somewhere currently unmapped mmap private fixed at somewhere already mapped mmap shared not fixed mmap shared fixed at somewhere currently unmapped mmap shared fixed at somewhere already mapped For private mappings, we should verify that changes cannot be read() back from the file, nor mmap's back from the file at a different address. (There have been systems where private was not correctly implemented like the infamous i386 svr4.0, and systems where the VM page cache was not coherent with the file system buffer cache like early versions of FreeBSD and possibly contemporary NetBSD.) For shared mappings, we should conversely verify that changes get propagated back to all the places they're supposed to be. Grep wants private fixed already mapped. The main things grep needs to know about mmap are: * does it exist and is it safe to write into the mmap'd area * how to use it (BSD variants) */ #include #include #if !defined STDC_HEADERS && !defined HAVE_STDLIB_H char *malloc (); #endif /* This mess was copied from the GNU getpagesize.h. */ #ifndef HAVE_GETPAGESIZE /* Assume that all systems that can run configure have sys/param.h. */ # ifndef HAVE_SYS_PARAM_H # define HAVE_SYS_PARAM_H 1 # endif # ifdef _SC_PAGESIZE # define getpagesize() sysconf(_SC_PAGESIZE) # else /* no _SC_PAGESIZE */ # ifdef HAVE_SYS_PARAM_H # include # ifdef EXEC_PAGESIZE # define getpagesize() EXEC_PAGESIZE # else /* no EXEC_PAGESIZE */ # ifdef NBPG # define getpagesize() NBPG * CLSIZE # ifndef CLSIZE # define CLSIZE 1 # endif /* no CLSIZE */ # else /* no NBPG */ # ifdef NBPC # define getpagesize() NBPC # else /* no NBPC */ # ifdef PAGESIZE # define getpagesize() PAGESIZE # endif /* PAGESIZE */ # endif /* no NBPC */ # endif /* no NBPG */ # endif /* no EXEC_PAGESIZE */ # else /* no HAVE_SYS_PARAM_H */ # define getpagesize() 8192 /* punt totally */ # endif /* no HAVE_SYS_PARAM_H */ # endif /* no _SC_PAGESIZE */ #endif /* no HAVE_GETPAGESIZE */ int main () { char *data, *data2, *data3; int i, pagesize; int fd; pagesize = getpagesize (); /* First, make a file with some known garbage in it. */ data = (char *) malloc (pagesize); if (!data) return 1; for (i = 0; i < pagesize; ++i) *(data + i) = rand (); umask (0); fd = creat ("conftest.mmap", 0600); if (fd < 0) return 1; if (write (fd, data, pagesize) != pagesize) return 1; close (fd); /* Next, try to mmap the file at a fixed address which already has something else allocated at it. If we can, also make sure that we see the same garbage. */ fd = open ("conftest.mmap", O_RDWR); if (fd < 0) return 1; data2 = (char *) malloc (2 * pagesize); if (!data2) return 1; data2 += (pagesize - ((long int) data2 & (pagesize - 1))) & (pagesize - 1); if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, 0L)) return 1; for (i = 0; i < pagesize; ++i) if (*(data + i) != *(data2 + i)) return 1; /* Finally, make sure that changes to the mapped area do not percolate back to the file as seen by read(). (This is a bug on some variants of i386 svr4.0.) */ for (i = 0; i < pagesize; ++i) *(data2 + i) = *(data2 + i) + 1; data3 = (char *) malloc (pagesize); if (!data3) return 1; if (read (fd, data3, pagesize) != pagesize) return 1; for (i = 0; i < pagesize; ++i) if (*(data + i) != *(data3 + i)) return 1; close (fd); return 0; } #define PACKAGE_NAME "bufferpool" #define PACKAGE_TARNAME "bufferpool" #define PACKAGE_VERSION "0.0.1" #define PACKAGE_STRING "bufferpool 0.0.1" #define PACKAGE_BUGREPORT "" #define PACKAGE "bufferpool" #define VERSION "0.0.1" #define HAVE_DLFCN_H 1 #define TIME_WITH_SYS_TIME 1 #define HAVE_SYS_TIME_H 1 #define HAVE_ERRNO_H 1 #define WORDS_BIGENDIAN 1 #define HAVE_SYS_ERRNO_H 1 #define HAVE_DIRENT_H 1 #define HAVE_FCNTL_H 1 #define HAVE_MALLOC_H 1 #define HAVE_SYS_TIME_H 1 #define size_t unsigned int #define HAVE_ERRNO_H 1 #define pid_t int #define TIME_WITH_SYS_TIME 1 #define HAVE_SYS_ERRNO_H 1 #define HAVE_FCNTL_H 1 #define HAVE_GETPAGESIZE 1 #define HAVE_MMAP 1 #define HAVE_MALLOC_H 1 #define size_t unsigned int #define pid_t int #ifndef __cplusplus #define inline __inline__ #endif #define HAVE_STRDUP 1 /* end confdefs.h. */ /* Define strstr to an innocuous variant, in case declares strstr. For example, HP-UX 11i declares gettimeofday. */ #define strstr innocuous_strstr /* System header to define __stub macros and hopefully few prototypes, which can conflict with char strstr (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef strstr /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char strstr (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_strstr || defined __stub___strstr choke me #endif int main () { return strstr (); ; return 0; }