diff options
author | kinichiro <kinichiro.inoguchi@gmail.com> | 2017-03-15 21:02:22 +0900 |
---|---|---|
committer | kinichiro <kinichiro.inoguchi@gmail.com> | 2017-03-15 22:02:11 +0900 |
commit | c61c9821e8417243a5a0cf691415f5e5626f2b3b (patch) | |
tree | a94dea834588dc0f9c8862e5a348b641302f4edd | |
parent | 8877e9bc55fdbdb70c967b7720f57fba148a7dda (diff) | |
download | portable-c61c9821e8417243a5a0cf691415f5e5626f2b3b.tar.gz portable-c61c9821e8417243a5a0cf691415f5e5626f2b3b.tar.bz2 portable-c61c9821e8417243a5a0cf691415f5e5626f2b3b.zip |
Add support for getpagesize
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | crypto/CMakeLists.txt | 4 | ||||
-rw-r--r-- | crypto/Makefile.am | 4 | ||||
-rw-r--r-- | crypto/compat/getpagesize.c | 18 | ||||
-rw-r--r-- | include/compat/unistd.h | 4 | ||||
-rw-r--r-- | m4/check-libc.m4 | 3 |
6 files changed, 33 insertions, 1 deletions
@@ -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) |
682 | endif() | 682 | endif() |
683 | 683 | ||
684 | if(NOT HAVE_GETPAGESIZE) | ||
685 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/getpagesize.c) | ||
686 | endif() | ||
687 | |||
684 | if(NOT HAVE_INET_PTON) | 688 | if(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 | |||
81 | libcompat_la_SOURCES += compat/bsd-asprintf.c | 81 | libcompat_la_SOURCES += compat/bsd-asprintf.c |
82 | endif | 82 | endif |
83 | 83 | ||
84 | if !HAVE_GETPAGESIZE | ||
85 | libcompat_la_SOURCES += compat/getpagesize.c | ||
86 | endif | ||
87 | |||
84 | if !HAVE_INET_PTON | 88 | if !HAVE_INET_PTON |
85 | libcompat_la_SOURCES += compat/inet_pton.c | 89 | libcompat_la_SOURCES += compat/inet_pton.c |
86 | endif | 90 | endif |
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 | |||
9 | int | ||
10 | getpagesize(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 | ||
43 | int 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 |
3 | AC_CHECK_HEADERS([err.h readpassphrase.h]) | 3 | AC_CHECK_HEADERS([err.h readpassphrase.h]) |
4 | # Check for general libc functions | 4 | # Check for general libc functions |
5 | AC_CHECK_FUNCS([asprintf inet_ntop inet_pton memmem readpassphrase]) | 5 | AC_CHECK_FUNCS([asprintf getpagesize inet_ntop inet_pton memmem readpassphrase]) |
6 | AC_CHECK_FUNCS([reallocarray recallocarray]) | 6 | AC_CHECK_FUNCS([reallocarray recallocarray]) |
7 | AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum]) | 7 | AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum]) |
8 | AC_CHECK_FUNCS([timegm _mkgmtime]) | 8 | AC_CHECK_FUNCS([timegm _mkgmtime]) |
9 | AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes]) | 9 | AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes]) |
10 | AM_CONDITIONAL([HAVE_GETPAGESIZE], [test "x$ac_cv_func_getpagesize" = xyes]) | ||
10 | AM_CONDITIONAL([HAVE_INET_NTOP], [test "x$ac_cv_func_inet_ntop" = xyes]) | 11 | AM_CONDITIONAL([HAVE_INET_NTOP], [test "x$ac_cv_func_inet_ntop" = xyes]) |
11 | AM_CONDITIONAL([HAVE_INET_PTON], [test "x$ac_cv_func_inet_pton" = xyes]) | 12 | AM_CONDITIONAL([HAVE_INET_PTON], [test "x$ac_cv_func_inet_pton" = xyes]) |
12 | AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes]) | 13 | AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes]) |