aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkinichiro <kinichiro.inoguchi@gmail.com>2017-03-15 21:02:22 +0900
committerkinichiro <kinichiro.inoguchi@gmail.com>2017-03-15 22:02:11 +0900
commitc61c9821e8417243a5a0cf691415f5e5626f2b3b (patch)
treea94dea834588dc0f9c8862e5a348b641302f4edd
parent8877e9bc55fdbdb70c967b7720f57fba148a7dda (diff)
downloadportable-c61c9821e8417243a5a0cf691415f5e5626f2b3b.tar.gz
portable-c61c9821e8417243a5a0cf691415f5e5626f2b3b.tar.bz2
portable-c61c9821e8417243a5a0cf691415f5e5626f2b3b.zip
Add support for getpagesize
-rw-r--r--.gitignore1
-rw-r--r--crypto/CMakeLists.txt4
-rw-r--r--crypto/Makefile.am4
-rw-r--r--crypto/compat/getpagesize.c18
-rw-r--r--include/compat/unistd.h4
-rw-r--r--m4/check-libc.m43
6 files changed, 33 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 5543d7a..052804e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -142,6 +142,7 @@ include/openssl/*.h
142!/crypto/compat/arc4random.h 142!/crypto/compat/arc4random.h
143!/crypto/compat/b_win.c 143!/crypto/compat/b_win.c
144!/crypto/compat/explicit_bzero_win.c 144!/crypto/compat/explicit_bzero_win.c
145!/crypto/compat/getpagesize.c
145!/crypto/compat/posix_win.c 146!/crypto/compat/posix_win.c
146!/crypto/compat/bsd_asprintf.c 147!/crypto/compat/bsd_asprintf.c
147!/crypto/compat/inet_pton.c 148!/crypto/compat/inet_pton.c
diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt
index cda4fb3..e36004a 100644
--- a/crypto/CMakeLists.txt
+++ b/crypto/CMakeLists.txt
@@ -681,6 +681,10 @@ if(NOT HAVE_ASPRINTF)
681 set(EXTRA_EXPORT ${EXTRA_EXPORT} vasprintf) 681 set(EXTRA_EXPORT ${EXTRA_EXPORT} vasprintf)
682endif() 682endif()
683 683
684if(NOT HAVE_GETPAGESIZE)
685 set(CRYPTO_SRC ${CRYPTO_SRC} compat/getpagesize.c)
686endif()
687
684if(NOT HAVE_INET_PTON) 688if(NOT HAVE_INET_PTON)
685 set(CRYPTO_SRC ${CRYPTO_SRC} compat/inet_pton.c) 689 set(CRYPTO_SRC ${CRYPTO_SRC} compat/inet_pton.c)
686 set(EXTRA_EXPORT ${EXTRA_EXPORT} inet_pton) 690 set(EXTRA_EXPORT ${EXTRA_EXPORT} inet_pton)
diff --git a/crypto/Makefile.am b/crypto/Makefile.am
index 78f3dd8..dc94a8c 100644
--- a/crypto/Makefile.am
+++ b/crypto/Makefile.am
@@ -81,6 +81,10 @@ if !HAVE_ASPRINTF
81libcompat_la_SOURCES += compat/bsd-asprintf.c 81libcompat_la_SOURCES += compat/bsd-asprintf.c
82endif 82endif
83 83
84if !HAVE_GETPAGESIZE
85libcompat_la_SOURCES += compat/getpagesize.c
86endif
87
84if !HAVE_INET_PTON 88if !HAVE_INET_PTON
85libcompat_la_SOURCES += compat/inet_pton.c 89libcompat_la_SOURCES += compat/inet_pton.c
86endif 90endif
diff --git a/crypto/compat/getpagesize.c b/crypto/compat/getpagesize.c
new file mode 100644
index 0000000..098efa9
--- /dev/null
+++ b/crypto/compat/getpagesize.c
@@ -0,0 +1,18 @@
1/* $OpenBSD$ */
2
3#include <unistd.h>
4
5#ifdef _MSC_VER
6#include <windows.h>
7#endif
8
9int
10getpagesize(void) {
11#ifdef _MSC_VER
12 SYSTEM_INFO system_info;
13 GetSystemInfo(&system_info);
14 return system_info.dwPageSize;
15#else
16 return sysconf(_SC_PAGESIZE);
17#endif
18}
diff --git a/include/compat/unistd.h b/include/compat/unistd.h
index b37a2f6..d596043 100644
--- a/include/compat/unistd.h
+++ b/include/compat/unistd.h
@@ -39,6 +39,10 @@ int getentropy(void *buf, size_t buflen);
39#endif 39#endif
40#endif 40#endif
41 41
42#ifndef HAVE_GETPAGESIZE
43int getpagesize(void);
44#endif
45
42#define pledge(request, paths) 0 46#define pledge(request, paths) 0
43 47
44#ifndef HAVE_PIPE2 48#ifndef HAVE_PIPE2
diff --git a/m4/check-libc.m4 b/m4/check-libc.m4
index 22f0b35..e61d412 100644
--- a/m4/check-libc.m4
+++ b/m4/check-libc.m4
@@ -2,11 +2,12 @@ AC_DEFUN([CHECK_LIBC_COMPAT], [
2# Check for libc headers 2# Check for libc headers
3AC_CHECK_HEADERS([err.h readpassphrase.h]) 3AC_CHECK_HEADERS([err.h readpassphrase.h])
4# Check for general libc functions 4# Check for general libc functions
5AC_CHECK_FUNCS([asprintf inet_ntop inet_pton memmem readpassphrase]) 5AC_CHECK_FUNCS([asprintf getpagesize inet_ntop inet_pton memmem readpassphrase])
6AC_CHECK_FUNCS([reallocarray recallocarray]) 6AC_CHECK_FUNCS([reallocarray recallocarray])
7AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum]) 7AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum])
8AC_CHECK_FUNCS([timegm _mkgmtime]) 8AC_CHECK_FUNCS([timegm _mkgmtime])
9AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes]) 9AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes])
10AM_CONDITIONAL([HAVE_GETPAGESIZE], [test "x$ac_cv_func_getpagesize" = xyes])
10AM_CONDITIONAL([HAVE_INET_NTOP], [test "x$ac_cv_func_inet_ntop" = xyes]) 11AM_CONDITIONAL([HAVE_INET_NTOP], [test "x$ac_cv_func_inet_ntop" = xyes])
11AM_CONDITIONAL([HAVE_INET_PTON], [test "x$ac_cv_func_inet_pton" = xyes]) 12AM_CONDITIONAL([HAVE_INET_PTON], [test "x$ac_cv_func_inet_pton" = xyes])
12AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes]) 13AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes])