_sd_to_udi.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* Copyright (C) 2007-2022 Free Software Foundation, Inc.
  2. This file is part of GCC.
  3. GCC is free software; you can redistribute it and/or modify it under
  4. the terms of the GNU General Public License as published by the Free
  5. Software Foundation; either version 3, or (at your option) any later
  6. version.
  7. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  8. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  10. for more details.
  11. Under Section 7 of GPL version 3, you are granted additional
  12. permissions described in the GCC Runtime Library Exception, version
  13. 3.1, as published by the Free Software Foundation.
  14. You should have received a copy of the GNU General Public License and
  15. a copy of the GCC Runtime Library Exception along with this program;
  16. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  17. <http://www.gnu.org/licenses/>. */
  18. #include "bid_conf.h"
  19. #include "bid_functions.h"
  20. #include "bid_gcc_intrinsics.h"
  21. UDItype
  22. __bid_fixunssddi (_Decimal32 x) {
  23. UDItype res = 0xbaddbaddbaddbaddull;
  24. UINT64 x64;
  25. union decimal32 ux;
  26. ux.d = x;
  27. x64 = __bid32_to_bid64 (ux.i);
  28. res = __bid64_to_uint64_xint (x64);
  29. if (res == 0x8000000000000000ull) res = 0; // for NaNs too
  30. return (res);
  31. }