From 6be4ed022f7ecb50662924d39d213d7ae399a62a Mon Sep 17 00:00:00 2001 From: Michael Ow Date: Thu, 18 Aug 2011 18:47:16 +0000 Subject: [PATCH] ICU-8452 Fix some more Cygwin MVSC and Cygwin GCC build issues X-SVN-Rev: 30541 --- icu4c/source/common/putil.cpp | 2 +- icu4c/source/common/putilimp.h | 8 +++--- icu4c/source/common/umapfile.h | 2 +- icu4c/source/common/unicode/platform.h | 28 +++++++++------------ icu4c/source/config/mh-cygwin-msvc | 2 +- icu4c/source/i18n/numfmt.cpp | 2 +- icu4c/source/i18n/timezone.cpp | 2 +- icu4c/source/i18n/winnmfmt.cpp | 4 +-- icu4c/source/i18n/winnmfmt.h | 4 +-- icu4c/source/io/ustdio.c | 2 +- icu4c/source/test/intltest/numfmtst.cpp | 2 +- icu4c/source/test/intltest/simplethread.cpp | 4 +-- icu4c/source/test/intltest/tsmthred.cpp | 2 +- icu4c/source/test/intltest/uobjtest.cpp | 2 ++ icu4c/source/test/intltest/winnmtst.cpp | 4 +-- icu4c/source/test/intltest/winnmtst.h | 4 +-- icu4c/source/test/threadtest/threadtest.cpp | 2 +- icu4c/source/tools/toolutil/toolutil.cpp | 4 +-- 18 files changed, 39 insertions(+), 41 deletions(-) diff --git a/icu4c/source/common/putil.cpp b/icu4c/source/common/putil.cpp index 82a397df4dc..48fa80cecd1 100644 --- a/icu4c/source/common/putil.cpp +++ b/icu4c/source/common/putil.cpp @@ -645,7 +645,7 @@ uprv_timezone() /* Note that U_TZNAME does *not* have to be tzname, but if it is, some platforms need to have it declared here. */ -#if defined(U_TZNAME) && (U_PLATFORM == U_PF_IRIX || U_PLATFORM_IS_DARWIN_BASED || U_PLATFORM == U_PF_CYGWIN) +#if defined(U_TZNAME) && (U_PLATFORM == U_PF_IRIX || U_PLATFORM_IS_DARWIN_BASED || (U_PLATFORM == U_PF_CYGWIN && !U_PLATFORM_USES_ONLY_WIN32_API)) /* RS6000 and others reject char **tzname. */ extern U_IMPORT char *U_TZNAME[]; #endif diff --git a/icu4c/source/common/putilimp.h b/icu4c/source/common/putilimp.h index d952b020f94..b101172cbbb 100644 --- a/icu4c/source/common/putilimp.h +++ b/icu4c/source/common/putilimp.h @@ -69,7 +69,7 @@ typedef size_t uintptr_t; #ifdef U_TZSET /* Use the predefined value. */ -#elif U_PLATFORM_HAS_WIN32_API +#elif U_PLATFORM_USES_ONLY_WIN32_API # define U_TZSET _tzset #else # define U_TZSET tzset @@ -79,7 +79,7 @@ typedef size_t uintptr_t; /* Use the predefined value. */ #elif U_PLATFORM_IS_LINUX_BASED # define U_TIMEZONE __timezone -#elif U_PLATFORM_HAS_WIN32_API +#elif U_PLATFORM_USES_ONLY_WIN32_API # define U_TIMEZONE _timezone #else # define U_TIMEZONE timezone @@ -87,7 +87,7 @@ typedef size_t uintptr_t; #ifdef U_TZNAME /* Use the predefined value. */ -#elif U_PLATFORM_HAS_WIN32_API +#elif U_PLATFORM_USES_ONLY_WIN32_API # define U_TZNAME _tzname #else # define U_TZNAME tzname @@ -103,7 +103,7 @@ typedef size_t uintptr_t; #ifdef U_HAVE_POPEN /* Use the predefined value. */ -#elif U_PLATFORM == U_PF_WINDOWS +#elif U_PLATFORM_USES_ONLY_WIN32_API # define U_HAVE_POPEN 0 #else # define U_HAVE_POPEN 1 diff --git a/icu4c/source/common/umapfile.h b/icu4c/source/common/umapfile.h index 1de9f412d7b..2995e381ed3 100644 --- a/icu4c/source/common/umapfile.h +++ b/icu4c/source/common/umapfile.h @@ -39,7 +39,7 @@ U_CFUNC void uprv_unmapFile(UDataMemory *pData); #if UCONFIG_NO_FILE_IO # define MAP_IMPLEMENTATION MAP_NONE -#elif U_PLATFORM_HAS_WIN32_API +#elif U_PLATFORM_USES_ONLY_WIN32_API # define MAP_IMPLEMENTATION MAP_WIN32 #elif U_HAVE_MMAP || U_PLATFORM == U_PF_OS390 # if U_PLATFORM == U_PF_OS390 && defined (OS390_STUBDATA) diff --git a/icu4c/source/common/unicode/platform.h b/icu4c/source/common/unicode/platform.h index cdde3f1fac8..adabf07c1d0 100644 --- a/icu4c/source/common/unicode/platform.h +++ b/icu4c/source/common/unicode/platform.h @@ -161,6 +161,16 @@ # define U_PLATFORM U_PF_UNKNOWN #endif +/** + * \def CYGWINMSVC + * Defined if this is Windows with Cygwin, but using MSVC rather than gcc. + * Otherwise undefined. + * @internal + */ +#if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER) +# define CYGWINMSVC +#endif + /** * \def U_PLATFORM_USES_ONLY_WIN32_API * Defines whether the platform uses only the Win32 API. @@ -169,7 +179,7 @@ */ #ifdef U_PLATFORM_USES_ONLY_WIN32_API /* Use the predefined value. */ -#elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW +#elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC) # define U_PLATFORM_USES_ONLY_WIN32_API 1 #else /* Cygwin implements POSIX. */ @@ -185,11 +195,7 @@ #ifdef U_PLATFORM_HAS_WIN32_API /* Use the predefined value. */ #elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN -# if U_PLATFORM == U_PF_CYGWIN && defined(__GNUC__) -# define U_PLATFORM_HAS_WIN32_API 0 -# else -# define U_PLATFORM_HAS_WIN32_API 1 -# endif +# define U_PLATFORM_HAS_WIN32_API 1 #else # define U_PLATFORM_HAS_WIN32_API 0 #endif @@ -208,16 +214,6 @@ # define U_PLATFORM_IMPLEMENTS_POSIX 1 #endif -/** - * \def CYGWINMSVC - * Defined if this is Windows with Cygwin, but using MSVC rather than gcc. - * Otherwise undefined. - * @internal - */ -#if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER) -# define CYGWINMSVC -#endif - /** * \def U_PLATFORM_IS_LINUX_BASED * Defines whether the platform is Linux or one of its derivatives. diff --git a/icu4c/source/config/mh-cygwin-msvc b/icu4c/source/config/mh-cygwin-msvc index e07b5a7bc93..053ee48dae5 100644 --- a/icu4c/source/config/mh-cygwin-msvc +++ b/icu4c/source/config/mh-cygwin-msvc @@ -48,7 +48,7 @@ endif CFLAGS+=/GF /nologo CXXFLAGS+=/GF /nologo /EHsc /Zc:wchar_t CPPFLAGS+=-D_CRT_SECURE_NO_DEPRECATE -DEFS+=-DWIN32 +DEFS+=-DWIN32 -D__CYGWIN__ LDFLAGS+=/nologo # Commands to compile diff --git a/icu4c/source/i18n/numfmt.cpp b/icu4c/source/i18n/numfmt.cpp index 86c23799820..692107c0805 100644 --- a/icu4c/source/i18n/numfmt.cpp +++ b/icu4c/source/i18n/numfmt.cpp @@ -1120,7 +1120,7 @@ NumberFormat::makeInstance(const Locale& desiredLocale, return NULL; } -#if U_PLATFORM_HAS_WIN32_API +#if U_PLATFORM_USES_ONLY_WIN32_API char buffer[8]; int32_t count = desiredLocale.getKeywordValue("compat", buffer, sizeof(buffer), status); diff --git a/icu4c/source/i18n/timezone.cpp b/icu4c/source/i18n/timezone.cpp index 263e68d1af8..01a86ebf1bd 100644 --- a/icu4c/source/i18n/timezone.cpp +++ b/icu4c/source/i18n/timezone.cpp @@ -493,7 +493,7 @@ TimeZone::initDefault() hostStrID.truncate(hostStrID.length()-1); default_zone = createSystemTimeZone(hostStrID); -#if U_PLATFORM_HAS_WIN32_API +#if U_PLATFORM_USES_ONLY_WIN32_API // hostID points to a heap-allocated location on Windows. uprv_free(const_cast(hostID)); #endif diff --git a/icu4c/source/i18n/winnmfmt.cpp b/icu4c/source/i18n/winnmfmt.cpp index 97e730f538b..74136d0b56a 100644 --- a/icu4c/source/i18n/winnmfmt.cpp +++ b/icu4c/source/i18n/winnmfmt.cpp @@ -11,7 +11,7 @@ #include "unicode/utypes.h" -#if U_PLATFORM_HAS_WIN32_API +#if U_PLATFORM_USES_ONLY_WIN32_API #if !UCONFIG_NO_FORMATTING @@ -351,4 +351,4 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ -#endif // U_PLATFORM_HAS_WIN32_API +#endif // U_PLATFORM_USES_ONLY_WIN32_API diff --git a/icu4c/source/i18n/winnmfmt.h b/icu4c/source/i18n/winnmfmt.h index f4474d8d73c..e75adf9e7e3 100644 --- a/icu4c/source/i18n/winnmfmt.h +++ b/icu4c/source/i18n/winnmfmt.h @@ -14,7 +14,7 @@ #include "unicode/utypes.h" -#if U_PLATFORM_HAS_WIN32_API +#if U_PLATFORM_USES_ONLY_WIN32_API #include "unicode/format.h" #include "unicode/datefmt.h" @@ -156,6 +156,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ -#endif // U_PLATFORM_HAS_WIN32_API +#endif // U_PLATFORM_USES_ONLY_WIN32_API #endif // __WINNMFMT diff --git a/icu4c/source/io/ustdio.c b/icu4c/source/io/ustdio.c index c7e8751da74..14bdb9867c4 100644 --- a/icu4c/source/io/ustdio.c +++ b/icu4c/source/io/ustdio.c @@ -37,7 +37,7 @@ #define DELIM_PS 0x2029 /* TODO: is this correct for all codepages? Should we just use \n and let the converter handle it? */ -#if U_PLATFORM_HAS_WIN32_API +#if U_PLATFORM_USES_ONLY_WIN32_API static const UChar DELIMITERS [] = { DELIM_CR, DELIM_LF, 0x0000 }; static const uint32_t DELIMITERS_LEN = 2; /* TODO: Default newline writing should be detected based upon the converter being used. */ diff --git a/icu4c/source/test/intltest/numfmtst.cpp b/icu4c/source/test/intltest/numfmtst.cpp index 37d5acec67f..1842bb63cdb 100644 --- a/icu4c/source/test/intltest/numfmtst.cpp +++ b/icu4c/source/test/intltest/numfmtst.cpp @@ -2621,7 +2621,7 @@ void NumberFormatTest::TestJB3832(){ void NumberFormatTest::TestHost() { -#if U_PLATFORM_HAS_WIN32_API +#if U_PLATFORM_USES_ONLY_WIN32_API Win32NumberTest::testLocales(this); #endif Locale loc("en_US@compat=host"); diff --git a/icu4c/source/test/intltest/simplethread.cpp b/icu4c/source/test/intltest/simplethread.cpp index ea7518c6e86..b903173e170 100644 --- a/icu4c/source/test/intltest/simplethread.cpp +++ b/icu4c/source/test/intltest/simplethread.cpp @@ -37,7 +37,7 @@ #include #include // tolower, toupper -#if U_PLATFORM_HAS_WIN32_API +#if U_PLATFORM_USES_ONLY_WIN32_API /* Prefer native Windows APIs even if POSIX is implemented (i.e., on Cygwin). */ # undef POSIX #elif U_PLATFORM_IMPLEMENTS_POSIX @@ -137,7 +137,7 @@ #include "unicode/calendar.h" #include "ucaconf.h" -#if U_PLATFORM_HAS_WIN32_API +#if U_PLATFORM_USES_ONLY_WIN32_API #define HAVE_IMP # define VC_EXTRALEAN diff --git a/icu4c/source/test/intltest/tsmthred.cpp b/icu4c/source/test/intltest/tsmthred.cpp index 8edeafd853e..a718fa5ff4e 100644 --- a/icu4c/source/test/intltest/tsmthred.cpp +++ b/icu4c/source/test/intltest/tsmthred.cpp @@ -25,7 +25,7 @@ #include "unicode/locid.h" #include "putilimp.h" -#if U_PLATFORM_HAS_WIN32_API +#if U_PLATFORM_USES_ONLY_WIN32_API /* Prefer native Windows APIs even if POSIX is implemented (i.e., on Cygwin). */ # undef POSIX #elif U_PLATFORM_IMPLEMENTS_POSIX diff --git a/icu4c/source/test/intltest/uobjtest.cpp b/icu4c/source/test/intltest/uobjtest.cpp index 83d1ac7fc8e..4639966d903 100644 --- a/icu4c/source/test/intltest/uobjtest.cpp +++ b/icu4c/source/test/intltest/uobjtest.cpp @@ -382,9 +382,11 @@ void UObjectTest::testIDs() TESTCLASSID_FACTORY(TaiwanCalendar, Calendar::createInstance(Locale("@calendar=roc"), status)); #if U_PLATFORM_HAS_WIN32_API TESTCLASSID_FACTORY(Win32DateFormat, DateFormat::createDateInstance(DateFormat::kFull, Locale("@compat=host"))); +#if U_PLATFORM_USES_ONLY_WIN32_API TESTCLASSID_FACTORY(Win32NumberFormat, NumberFormat::createInstance(Locale("@compat=host"), status)); #endif #endif +#endif #if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILE_IO /* TESTCLASSID_ABSTRACT(BreakIterator); No staticID! */ diff --git a/icu4c/source/test/intltest/winnmtst.cpp b/icu4c/source/test/intltest/winnmtst.cpp index d09c1fec87c..9a548e1990d 100644 --- a/icu4c/source/test/intltest/winnmtst.cpp +++ b/icu4c/source/test/intltest/winnmtst.cpp @@ -11,7 +11,7 @@ #include "unicode/utypes.h" -#if U_PLATFORM_HAS_WIN32_API +#if U_PLATFORM_USES_ONLY_WIN32_API #if !UCONFIG_NO_FORMATTING @@ -320,4 +320,4 @@ void Win32NumberTest::testLocales(TestLog *log) #endif /* #if !UCONFIG_NO_FORMATTING */ -#endif /* U_PLATFORM_HAS_WIN32_API */ +#endif /* U_PLATFORM_USES_ONLY_WIN32_API */ diff --git a/icu4c/source/test/intltest/winnmtst.h b/icu4c/source/test/intltest/winnmtst.h index 440c9871268..655a0b35fdc 100644 --- a/icu4c/source/test/intltest/winnmtst.h +++ b/icu4c/source/test/intltest/winnmtst.h @@ -14,7 +14,7 @@ #include "unicode/utypes.h" -#if U_PLATFORM_HAS_WIN32_API +#if U_PLATFORM_USES_ONLY_WIN32_API #if !UCONFIG_NO_FORMATTING @@ -36,6 +36,6 @@ private: #endif /* #if !UCONFIG_NO_FORMATTING */ -#endif // U_PLATFORM_HAS_WIN32_API +#endif // U_PLATFORM_USES_ONLY_WIN32_API #endif // __WINNMTST diff --git a/icu4c/source/test/threadtest/threadtest.cpp b/icu4c/source/test/threadtest/threadtest.cpp index 41d606cf095..85e53a552a4 100644 --- a/icu4c/source/test/threadtest/threadtest.cpp +++ b/icu4c/source/test/threadtest/threadtest.cpp @@ -33,7 +33,7 @@ extern AbstractThreadTest *createConvertTest(); // Windows specific code for starting threads // //------------------------------------------------------------------------------ -#if U_PLATFORM_HAS_WIN32_API +#if U_PLATFORM_USES_ONLY_WIN32_API #include "Windows.h" #include "process.h" diff --git a/icu4c/source/tools/toolutil/toolutil.cpp b/icu4c/source/tools/toolutil/toolutil.cpp index 41d552d14e7..bef774f4be4 100644 --- a/icu4c/source/tools/toolutil/toolutil.cpp +++ b/icu4c/source/tools/toolutil/toolutil.cpp @@ -22,7 +22,7 @@ #include #include "unicode/utypes.h" -#if U_PLATFORM_HAS_WIN32_API +#if U_PLATFORM_USES_ONLY_WIN32_API # define VC_EXTRALEAN # define WIN32_LEAN_AND_MEAN # define NOUSER @@ -86,7 +86,7 @@ U_CAPI int32_t U_EXPORT2 getCurrentYear() { U_CAPI const char * U_EXPORT2 getLongPathname(const char *pathname) { -#if U_PLATFORM_HAS_WIN32_API +#if U_PLATFORM_USES_ONLY_WIN32_API /* anticipate problems with "short" pathnames */ static WIN32_FIND_DATAA info; HANDLE file=FindFirstFileA(pathname, &info); -- 2.40.0