| 338 | |
| 339 | |
| 340 | bool_t xdr_double(xdr_t* xdrs, double* ip) |
| 341 | { |
| 342 | /************************************** |
| 343 | * |
| 344 | * x d r _ d o u b l e |
| 345 | * |
| 346 | ************************************** |
| 347 | * |
| 348 | * Functional description |
| 349 | * Map from external to internal representation (or vice versa). |
| 350 | * |
| 351 | **************************************/ |
| 352 | union { |
| 353 | double temp_double; |
| 354 | SLONG temp_long[2]; |
| 355 | } temp; |
| 356 | |
| 357 | fb_assert(sizeof(double) == sizeof(temp)); |
| 358 | |
| 359 | switch (xdrs->x_op) |
| 360 | { |
| 361 | case XDR_ENCODE: |
| 362 | temp.temp_double = *ip; |
| 363 | if (PUTLONG(xdrs, &temp.temp_long[FB_LONG_DOUBLE_FIRST]) && |
| 364 | PUTLONG(xdrs, &temp.temp_long[FB_LONG_DOUBLE_SECOND])) |
| 365 | { |
| 366 | return TRUE; |
| 367 | } |
| 368 | return FALSE; |
| 369 | |
| 370 | case XDR_DECODE: |
| 371 | if (!GETLONG(xdrs, &temp.temp_long[FB_LONG_DOUBLE_FIRST]) || |
| 372 | !GETLONG(xdrs, &temp.temp_long[FB_LONG_DOUBLE_SECOND])) |
| 373 | { |
| 374 | return FALSE; |
| 375 | } |
| 376 | *ip = temp.temp_double; |
| 377 | return TRUE; |
| 378 | |
| 379 | case XDR_FREE: |
| 380 | return TRUE; |
| 381 | } |
| 382 | |
| 383 | return FALSE; |
| 384 | } |
| 385 | |
| 386 | /* |
| 387 | DecFloat (at least as implemented in IBM's library) has a kind of PDP-endian format: |
no test coverage detected