diff options
author | teor <teor2345@gmail.com> | 2016-11-03 08:44:57 +1100 |
---|---|---|
committer | teor <teor2345@gmail.com> | 2016-11-03 08:44:57 +1100 |
commit | 8f465808a06c739d8f81d04f6ed07fad40cacc76 (patch) | |
tree | 9e5023b6c5cec779efccebbe08d6e217abeb5d51 /src/common/compat.c | |
parent | ff3e08f2af226d9660a08ab599c7e446c42fd7b4 (diff) | |
download | tor-8f465808a06c739d8f81d04f6ed07fad40cacc76.tar.gz tor-8f465808a06c739d8f81d04f6ed07fad40cacc76.zip |
Check for getpagesize before using it to mmap files
This fixes compilation in some MinGW environments.
Fixes bug 20530; bugfix on commit bf72878 in tor-0.1.2.1-alpha.
Reported by "ice".
Diffstat (limited to 'src/common/compat.c')
-rw-r--r-- | src/common/compat.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index 4f2f9778f2..5d751f8c28 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -204,7 +204,15 @@ tor_rename(const char *path_old, const char *path_new) sandbox_intern_string(path_new)); } -#if defined(HAVE_SYS_MMAN_H) || defined(RUNNING_DOXYGEN) +/* Some MinGW builds have sys/mman.h, but not the corresponding symbols. + * Other configs rename the symbols using macros (including getpagesize). + * So check for sys/mman.h and unistd.h, and a getpagesize declaration. */ +#if (defined(HAVE_SYS_MMAN_H) && defined(HAVE_UNISTD_H) && \ + defined(HAVE_DECL_GETPAGESIZE)) +#define COMPAT_HAS_MMAN_AND_PAGESIZE +#endif + +#if defined(COMPAT_HAS_MMAN_AND_PAGESIZE) || defined(RUNNING_DOXYGEN) /** Try to create a memory mapping for <b>filename</b> and return it. On * failure, return NULL. Sets errno properly, using ERANGE to mean * "empty file". */ |