From: Michihiro NAKAJIMA Date: Thu, 25 Feb 2010 18:13:07 +0000 (-0500) Subject: Portability. X-Git-Tag: v3.0.0a~1179 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=593c0d35734e761213ae8ab039f928d3eca9ad65;p=thirdparty%2Flibarchive.git Portability. SVN-Revision: 1993 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 78ca81efc..16921adae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -390,6 +390,7 @@ CHECK_FUNCTION_EXISTS_GLIBC(lchflags HAVE_LCHFLAGS) CHECK_FUNCTION_EXISTS_GLIBC(lchmod HAVE_LCHMOD) CHECK_FUNCTION_EXISTS_GLIBC(lchown HAVE_LCHOWN) CHECK_FUNCTION_EXISTS_GLIBC(link HAVE_LINK) +CHECK_FUNCTION_EXISTS_GLIBC(localtime_r HAVE_LOCALTIME_R) CHECK_FUNCTION_EXISTS_GLIBC(lstat HAVE_LSTAT) CHECK_FUNCTION_EXISTS_GLIBC(lutimes HAVE_LUTIMES) CHECK_FUNCTION_EXISTS_GLIBC(mbrtowc HAVE_MBRTOWC) @@ -423,6 +424,7 @@ CHECK_FUNCTION_EXISTS_GLIBC(wcrtomb HAVE_WCRTOMB) CHECK_FUNCTION_EXISTS_GLIBC(wcscpy HAVE_WCSCPY) CHECK_FUNCTION_EXISTS_GLIBC(wcslen HAVE_WCSLEN) CHECK_FUNCTION_EXISTS_GLIBC(wctomb HAVE_WCTOMB) +CHECK_FUNCTION_EXISTS_GLIBC(_localtime64_s HAVE_LOCALTIME64_S) CHECK_FUNCTION_EXISTS_GLIBC(_mkgmtime64 HAVE__MKGMTIME64) CHECK_SYMBOL_EXISTS(wmemcmp "wchar.h" HAVE_WMEMCMP) CHECK_SYMBOL_EXISTS(wmemcpy "wchar.h" HAVE_WMEMCPY) diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index 2669616a2..73eb9a5e8 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -280,6 +280,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_LOCALE_H 1 +/* Define to 1 if you have the `localtime_r' function. */ +#cmakedefine HAVE_LOCALTIME_R 1 + /* Define to 1 if the system has the type `long long int'. */ #cmakedefine HAVE_LONG_LONG_INT 1 @@ -641,6 +644,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_ZLIB_H 1 +/* Define to 1 if you have the `_localtime64_s' function. */ +#cmakedefine HAVE__LOCALTIME64_S 1 + /* Define to 1 if you have the `_mkgmtime64' function. */ #cmakedefine HAVE__MKGMTIME64 1 diff --git a/configure.ac b/configure.ac index 925d73397..9c4ff397d 100644 --- a/configure.ac +++ b/configure.ac @@ -400,7 +400,7 @@ AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *]) AC_CHECK_FUNCS([chflags chown chroot]) AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fork]) AC_CHECK_FUNCS([fstat ftruncate futimens futimes geteuid getpid]) -AC_CHECK_FUNCS([lchflags lchmod lchown link lstat]) +AC_CHECK_FUNCS([lchflags lchmod lchown link localtime_r lstat]) AC_CHECK_FUNCS([lutimes mbrtowc memmove memset mkdir mkfifo mknod mkstemp]) AC_CHECK_FUNCS([nl_langinfo pipe poll readlink]) AC_CHECK_FUNCS([select setenv setlocale sigaction]) diff --git a/libarchive/archive_windows.h b/libarchive/archive_windows.h index bd9e2e49b..1c90ddcf0 100644 --- a/libarchive/archive_windows.h +++ b/libarchive/archive_windows.h @@ -58,7 +58,6 @@ #include #endif #include -#include #include #include #include @@ -111,7 +110,6 @@ #define link __la_link #define lseek __la_lseek #define lstat __la_stat -#define localtime_r(time, tm) localtime_s(tm, time) #define mbstowcs __la_mbstowcs #define mkdir(d,m) __la_mkdir(d, m) #define open __la_open diff --git a/libarchive/archive_write_set_format_iso9660.c b/libarchive/archive_write_set_format_iso9660.c index 75e25125d..06369d836 100644 --- a/libarchive/archive_write_set_format_iso9660.c +++ b/libarchive/archive_write_set_format_iso9660.c @@ -2571,8 +2571,14 @@ set_date_time(unsigned char *p, time_t t) { struct tm tm; +#if HAVE_LOCALTIME_R tzset(); localtime_r(&t, &tm); +#elif HAVE__LOCALTIME64_S + _localtime64_s(&tm, &t) +#else + memcpy(&tm, localtime(&t), sizeof(tm)); +#endif set_digit(p, 4, tm.tm_year + 1900); set_digit(p+4, 2, tm.tm_mon + 1); set_digit(p+6, 2, tm.tm_mday); @@ -2595,8 +2601,14 @@ set_time_915(unsigned char *p, time_t t) { struct tm tm; +#if HAVE_LOCALTIME_R tzset(); localtime_r(&t, &tm); +#elif HAVE__LOCALTIME64_S + _localtime64_s(&tm, &t) +#else + memcpy(&tm, localtime(&t), sizeof(tm)); +#endif set_num_711(p+0, tm.tm_year); set_num_711(p+1, tm.tm_mon+1); set_num_711(p+2, tm.tm_mday);