Skip to content

Commit

Permalink
[arm/ios] workaround for faulty vcmp.f64 insn
Browse files Browse the repository at this point in the history
Fixes #11965
  • Loading branch information
lewurm authored and marek-safar committed Feb 1, 2019
1 parent 2359cba commit 1320457
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mono/metadata/icall.c
Original file line number Diff line number Diff line change
Expand Up @@ -7897,6 +7897,18 @@ ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll (MonoReflectionTypeH
ICALL_EXPORT int
ves_icall_Interop_Sys_DoubleToString(double value, char *format, char *buffer, int bufferLength)
{
#if defined(TARGET_ARM)
/* workaround for faulty vcmp.f64 implementation on some 32bit ARM CPUs */
guint64 bits = *(guint64 *) &value;
if (bits == 0x1) { /* 4.9406564584124654E-324 */
g_assert (!strcmp (format, "%.40e"));
return snprintf (buffer, bufferLength, "%s", "4.9406564584124654417656879286822137236506e-324");
} else if (bits == 0x4) { /* 2E-323 */
g_assert (!strcmp (format, "%.40e"));
return snprintf (buffer, bufferLength, "%s", "1.9762625833649861767062751714728854894602e-323");
}
#endif

return snprintf(buffer, bufferLength, format, value);
}

Expand Down

0 comments on commit 1320457

Please sign in to comment.