X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/f3c0d7a59d99c2a94c6b8822291f0e42be3773c9..a01113dcd0f39d5da295ef82785beff9ed86fe38:/icuSources/i18n/islamcal.cpp diff --git a/icuSources/i18n/islamcal.cpp b/icuSources/i18n/islamcal.cpp index 4fd0e07d..b44b60c3 100644 --- a/icuSources/i18n/islamcal.cpp +++ b/icuSources/i18n/islamcal.cpp @@ -54,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; @@ -223,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; } @@ -473,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) { @@ -484,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; @@ -614,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); @@ -675,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;