| 1437 | } |
| 1438 | |
| 1439 | static void |
| 1440 | DeserializeFloatInlined(char *pBuffer, size_t zBUfferLength, struct CTypeDescriptor *pType, unsigned long ulNumber) |
| 1441 | { |
| 1442 | float F; |
| 1443 | double D; |
| 1444 | uint32_t U32; |
| 1445 | |
| 1446 | ASSERT(pBuffer); |
| 1447 | ASSERT(zBUfferLength > 0); |
| 1448 | ASSERT(pType); |
| 1449 | ASSERT(sizeof(F) == sizeof(uint32_t)); |
| 1450 | ASSERT(sizeof(D) == sizeof(uint64_t)); |
| 1451 | |
| 1452 | switch (zDeserializeTypeWidth(pType)) { |
| 1453 | case WIDTH_64: |
| 1454 | memcpy(&D, &ulNumber, sizeof(double)); |
| 1455 | snprintf(pBuffer, zBUfferLength, "%g", D); |
| 1456 | break; |
| 1457 | case WIDTH_32: |
| 1458 | /* |
| 1459 | * On supported platforms sizeof(float)==sizeof(uint32_t) |
| 1460 | * unsigned long is either 32 or 64-bit, cast it to 32-bit |
| 1461 | * value in order to call memcpy(3) in an Endian-aware way. |
| 1462 | */ |
| 1463 | U32 = STATIC_CAST(uint32_t, ulNumber); |
| 1464 | memcpy(&F, &U32, sizeof(float)); |
| 1465 | snprintf(pBuffer, zBUfferLength, "%g", F); |
| 1466 | break; |
| 1467 | case WIDTH_16: |
| 1468 | snprintf(pBuffer, zBUfferLength, "Undecoded-16-bit-Floating-Type (%#04" PRIx16 ")", STATIC_CAST(uint16_t, ulNumber)); |
| 1469 | break; |
| 1470 | } |
| 1471 | } |
| 1472 | #endif |
| 1473 | |
| 1474 | static longest |
no test coverage detected