From 1fb8c9c6bea797e4db5e395fb34b899682ee8682 Mon Sep 17 00:00:00 2001 From: kinichiro Date: Sun, 18 Mar 2018 00:38:14 +0900 Subject: Fix using right functions for file descriptor with MS Visual Studio --- patches/keypairtest.c.patch | 13 +++++++++++++ patches/tls_config.c.patch | 13 +++++++++++++ patches/tls_util.c.patch | 13 +++++++++++++ tests/CMakeLists.txt | 2 -- tls/compat/ftruncate.c | 4 ++++ tls/compat/getuid.c | 4 ++++ tls/compat/pread.c | 6 ++++++ tls/compat/pwrite.c | 6 ++++++ 8 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 patches/keypairtest.c.patch create mode 100644 patches/tls_config.c.patch create mode 100644 patches/tls_util.c.patch diff --git a/patches/keypairtest.c.patch b/patches/keypairtest.c.patch new file mode 100644 index 0000000..b1f03da --- /dev/null +++ b/patches/keypairtest.c.patch @@ -0,0 +1,13 @@ +--- tests/keypairtest.c.orig Sun Mar 18 00:31:20 2018 ++++ tests/keypairtest.c Sun Mar 18 00:31:33 2018 +@@ -15,6 +15,10 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#ifdef _MSC_VER ++#define NO_REDEF_POSIX_FUNCTIONS ++#endif ++ + #include + + #include diff --git a/patches/tls_config.c.patch b/patches/tls_config.c.patch new file mode 100644 index 0000000..5702a58 --- /dev/null +++ b/patches/tls_config.c.patch @@ -0,0 +1,13 @@ +--- tls/tls_config.c.orig Sun Mar 18 00:29:59 2018 ++++ tls/tls_config.c Sun Mar 18 00:30:51 2018 +@@ -15,6 +15,10 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#ifdef _MSC_VER ++#define NO_REDEF_POSIX_FUNCTIONS ++#endif ++ + #include + + #include diff --git a/patches/tls_util.c.patch b/patches/tls_util.c.patch new file mode 100644 index 0000000..10f2f99 --- /dev/null +++ b/patches/tls_util.c.patch @@ -0,0 +1,13 @@ +--- tls/tls_util.c.orig Sun Mar 18 00:30:07 2018 ++++ tls/tls_util.c Sun Mar 18 00:31:09 2018 +@@ -17,6 +17,10 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#ifdef _MSC_VER ++#define NO_REDEF_POSIX_FUNCTIONS ++#endif ++ + #include + + #include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b6d94bf..bbb27d6 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -215,14 +215,12 @@ target_link_libraries(igetest ${TESTS_LIBS}) add_test(igetest igetest) # keypairtest -if(NOT MSVC) add_executable(keypairtest keypairtest.c) target_link_libraries(keypairtest ${TESTS_LIBS}) add_test(keypairtest keypairtest ${CMAKE_CURRENT_SOURCE_DIR}/ca.pem ${CMAKE_CURRENT_SOURCE_DIR}/server.pem ${CMAKE_CURRENT_SOURCE_DIR}/server.pem) -endif() # md4test add_executable(md4test md4test.c) diff --git a/tls/compat/ftruncate.c b/tls/compat/ftruncate.c index e68e6d0..e825e50 100644 --- a/tls/compat/ftruncate.c +++ b/tls/compat/ftruncate.c @@ -4,6 +4,8 @@ * Kinichiro Inoguchi */ +#ifdef _WIN32 + #include int @@ -11,3 +13,5 @@ ftruncate(int fd, off_t length) { return _chsize(fd, length); } + +#endif diff --git a/tls/compat/getuid.c b/tls/compat/getuid.c index 632967a..9a46317 100644 --- a/tls/compat/getuid.c +++ b/tls/compat/getuid.c @@ -4,6 +4,8 @@ * Kinichiro Inoguchi */ +#ifdef _WIN32 + #include uid_t @@ -12,3 +14,5 @@ getuid(void) /* Windows fstat sets 0 as st_uid */ return 0; } + +#endif diff --git a/tls/compat/pread.c b/tls/compat/pread.c index f0c9a2f..b9d6b09 100644 --- a/tls/compat/pread.c +++ b/tls/compat/pread.c @@ -4,6 +4,10 @@ * Kinichiro Inoguchi */ +#ifdef _WIN32 + +#define NO_REDEF_POSIX_FUNCTIONS + #include ssize_t @@ -21,3 +25,5 @@ pread(int d, void *buf, size_t nbytes, off_t offset) return -1; return bytes; } + +#endif diff --git a/tls/compat/pwrite.c b/tls/compat/pwrite.c index a304f7a..82f5f55 100644 --- a/tls/compat/pwrite.c +++ b/tls/compat/pwrite.c @@ -4,6 +4,10 @@ * Kinichiro Inoguchi */ +#ifdef _WIN32 + +#define NO_REDEF_POSIX_FUNCTIONS + #include ssize_t @@ -21,3 +25,5 @@ pwrite(int d, const void *buf, size_t nbytes, off_t offset) return -1; return bytes; } + +#endif -- cgit v1.2.3-55-g6feb