From: Tim Kientzle Date: Sun, 2 Aug 2009 18:34:07 +0000 (-0400) Subject: Another step towards clean Windows builds: libarchive, libarchive_test, and bsdtar_... X-Git-Tag: v2.8.0~478 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=606903d748253b0863187647dd9f1606f8cacbb7;p=thirdparty%2Flibarchive.git Another step towards clean Windows builds: libarchive, libarchive_test, and bsdtar_test all build cleanly now under both Visual C++ and MinGW. SVN-Revision: 1305 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 12ec0e8b7..21530a23d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -284,6 +284,8 @@ CHECK_FUNCTION_EXISTS(SHA512_Init HAVE_SHA512) # # Check functions # +CHECK_SYMBOL_EXISTS(CreateHardLink "windows.h" HAVE_CREATEHARDLINK) +CHECK_SYMBOL_EXISTS(CreateSymbolicLink "windows.h" HAVE_CREATESYMBOLICLINK) CHECK_FUNCS(chflags chown chroot) CHECK_FUNCS(fchdir fchflags fchmod fchown fcntl fork) CHECK_FUNCS(fstat ftruncate futimes geteuid getpid) diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index b24016bfa..4720aadaf 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -51,6 +51,12 @@ /* Define to 1 if you have the `chroot' function. */ #cmakedefine HAVE_CHROOT 1 +/* Define to 1 if you have the `CreateSymbolicLink function. */ +#cmakedefine HAVE_CREATESYMBOLICLINK 1 + +/* Define to 1 if you have the `CreateHardLink function. */ +#cmakedefine HAVE_CREATEHARDLINK 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_CTYPE_H 1 diff --git a/libarchive/test/main.c b/libarchive/test/main.c index 808771002..d59e35115 100644 --- a/libarchive/test/main.c +++ b/libarchive/test/main.c @@ -945,6 +945,9 @@ int test_assert_is_symlink(const char *file, int line, const char *pathname, const char *contents) { +#if defined(_WIN32) && !defined(__CYGWIN__) + return (0); +#else char buff[300]; struct stat st; ssize_t linklen; @@ -995,6 +998,7 @@ test_assert_is_symlink(const char *file, int line, return (0); } return (1); +#endif } int @@ -1061,10 +1065,12 @@ test_assert_make_hardlink(const char *file, int line, int succeeded; count_assertion(file, line); -#if defined(_WIN32) && !defined(__CYGWIN__) +#if HAVE_CREATEHARDLINK succeeded = CreateHardLink(newpath, linkto, NULL); -#else +#elif HAVE_LINK succeeded = !link(linkto, newpath); +#else + succeeded = 0; #endif if (succeeded) { msg[0] = '\0'; @@ -1087,13 +1093,15 @@ test_assert_make_symlink(const char *file, int line, { int succeeded; -#if defined(_WIN32) && !defined(__CYGWIN__) +#if HAVE_CREATESYMBOLICLINK int targetIsDir = 0; /* TODO: Fix this. */ count_assertion(file, line); succeeded = CreateSymbolicLink(newpath, linkto, targetIsDir); -#else +#elif HAVE_SYMLINK count_assertion(file, line); succeeded = !symlink(linkto, newpath); +#else + succeeded = 0; #endif if (succeeded) { msg[0] = '\0'; diff --git a/libarchive/test/test.h b/libarchive/test/test.h index 809cf66ce..ec8d072fd 100644 --- a/libarchive/test/test.h +++ b/libarchive/test/test.h @@ -63,14 +63,20 @@ #endif #include #include +#ifdef HAVE_IO_H +#include +#endif #include #include #include #include -#if !defined(_WIN32) || defined(__CYGWIN__) +#ifdef HAVE_UNISTD_H #include #endif #include +#ifdef HAVE_WINDOWS_H +#include +#endif #ifdef __FreeBSD__ diff --git a/libarchive/test/test_open_fd.c b/libarchive/test/test_open_fd.c index 18e461cbf..79cbba2ce 100644 --- a/libarchive/test/test_open_fd.c +++ b/libarchive/test/test_open_fd.c @@ -25,6 +25,11 @@ #include "test.h" __FBSDID("$FreeBSD$"); +#if defined(_WIN32) && !defined(__CYGWIN__) +#define open _open +#define lseek _lseek +#define close _close +#endif DEFINE_TEST(test_open_fd) { diff --git a/libarchive/test/test_read_data_large.c b/libarchive/test/test_read_data_large.c index f9a8ad44b..9487485bd 100644 --- a/libarchive/test/test_read_data_large.c +++ b/libarchive/test/test_read_data_large.c @@ -33,6 +33,11 @@ __FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_data_large.c,v 1.4 2008/09 * had a bug relating to this, fixed in Nov 2006). */ +#if defined(_WIN32) && !defined(__CYGWIN__) +#define open _open +#define close _close +#endif + char buff1[11000000]; char buff2[10000000]; char buff3[10000000]; diff --git a/libarchive/test/test_read_large.c b/libarchive/test/test_read_large.c index 1e72d473a..b98f07fe1 100644 --- a/libarchive/test/test_read_large.c +++ b/libarchive/test/test_read_large.c @@ -29,6 +29,11 @@ static unsigned char testdata[10 * 1024 * 1024]; static unsigned char testdatacopy[10 * 1024 * 1024]; static unsigned char buff[11 * 1024 * 1024]; +#if defined(_WIN32) && !defined(__CYGWIN__) +#define open _open +#define close _close +#endif + /* Check correct behavior on large reads. */ DEFINE_TEST(test_read_large) { diff --git a/tar/test/main.c b/tar/test/main.c index a061fcd19..8891e90fc 100644 --- a/tar/test/main.c +++ b/tar/test/main.c @@ -1069,10 +1069,12 @@ test_assert_make_hardlink(const char *file, int line, int succeeded; count_assertion(file, line); -#if defined(_WIN32) && !defined(__CYGWIN__) +#if HAVE_CREATEHARDLINK succeeded = CreateHardLink(newpath, linkto, NULL); -#else +#elif HAVE_LINK succeeded = !link(linkto, newpath); +#else + succeeded = 0; #endif if (succeeded) { msg[0] = '\0'; @@ -1095,13 +1097,15 @@ test_assert_make_symlink(const char *file, int line, { int succeeded; -#if defined(_WIN32) && !defined(__CYGWIN__) +#if HAVE_CREATESYMBOLICLINK int targetIsDir = 0; /* TODO: Fix this. */ count_assertion(file, line); succeeded = CreateSymbolicLink(newpath, linkto, targetIsDir); -#else +#elif HAVE_SYMLINK count_assertion(file, line); succeeded = !symlink(linkto, newpath); +#else + succeeded = 0; #endif if (succeeded) { msg[0] = '\0';