X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b331163bffd790ced0e88b73f44f86d49ccc48a5..3d1f044b704633e2e541231cd17ae9ecf9ad5c7a:/icuSources/i18n/islamcal.cpp diff --git a/icuSources/i18n/islamcal.cpp b/icuSources/i18n/islamcal.cpp index 0a9f0972..b44b60c3 100644 --- a/icuSources/i18n/islamcal.cpp +++ b/icuSources/i18n/islamcal.cpp @@ -1,3 +1,5 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ****************************************************************************** * Copyright (C) 2003-2015, International Business Machines Corporation @@ -52,7 +54,6 @@ static void debug_islamcal_msg(const char *pat, ...) // --- The cache -- // cache of months -static UMutex astroLock = U_MUTEX_INITIALIZER; // pod bay door lock static icu::CalendarCache *gMonthCache = NULL; static icu::CalendarAstronomer *gIslamicCalendarAstro = NULL; @@ -221,9 +222,7 @@ const char *IslamicCalendar::getType() const { sType = "islamic-umalqura"; break; default: - U_ASSERT(false); // out of range - sType = "islamic"; // "islamic" is used as the generic type - break; + UPRV_UNREACHABLE; // out of range } return sType; } @@ -471,7 +470,8 @@ double IslamicCalendar::moonAge(UDate time, UErrorCode &status) { double age = 0; - umtx_lock(&astroLock); + static UMutex *astroLock = STATIC_NEW(UMutex); // pod bay door lock + umtx_lock(astroLock); if(gIslamicCalendarAstro == NULL) { gIslamicCalendarAstro = new CalendarAstronomer(); if (gIslamicCalendarAstro == NULL) { @@ -482,7 +482,7 @@ double IslamicCalendar::moonAge(UDate time, UErrorCode &status) } gIslamicCalendarAstro->setTime(time); age = gIslamicCalendarAstro->getMoonAge(); - umtx_unlock(&astroLock); + umtx_unlock(astroLock); // Convert to degrees and normalize... age = age * 180 / CalendarAstronomer::PI; @@ -612,7 +612,7 @@ void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status) days = julianDay - ASTRONOMICAL_EPOC; } // Use the civil calendar approximation, which is just arithmetic - year = (int)ClockMath::floorDivide( (double)(30 * days + 10646) , 10631.0 ); + year = (int32_t)ClockMath::floorDivide(30 * (int64_t)days + 10646, (int64_t)10631); month = (int32_t)uprv_ceil((days - 29 - yearStart(year)) / 29.5 ); month = month<11?month:11; startDate = monthStart(year, month); @@ -673,8 +673,7 @@ void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status) month = m; } } else { // invalid 'civil' - U_ASSERT(false); // should not get here, out of range - year=month=0; + UPRV_UNREACHABLE; // should not get here, out of range } dayOfMonth = (days - monthStart(year, month)) + 1; @@ -734,7 +733,7 @@ int32_t IslamicCalendar::defaultCenturyStartYear() const } -void U_CALLCONV +U_CFUNC void U_CALLCONV IslamicCalendar::initializeSystemDefaultCentury() { // initialize systemDefaultCentury and systemDefaultCenturyYear based