| 1 |
/* Copyright (C) 2021-2025 Free Software Foundation, Inc. |
| 2 |
|
| 3 |
This file is free software; you can redistribute it and/or modify it |
| 4 |
under the terms of the GNU General Public License as published by the |
| 5 |
Free Software Foundation; either version 3, or (at your option) any |
| 6 |
later version. |
| 7 |
|
| 8 |
This file is distributed in the hope that it will be useful, but |
| 9 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
General Public License for more details. |
| 12 |
|
| 13 |
Under Section 7 of GPL version 3, you are granted additional |
| 14 |
permissions described in the GCC Runtime Library Exception, version |
| 15 |
3.1, as published by the Free Software Foundation. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License and |
| 18 |
a copy of the GCC Runtime Library Exception along with this program; |
| 19 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 20 |
<http://www.gnu.org/licenses/>. */ |
| 21 |
|
| 22 |
#include "lib2-gcn.h" |
| 23 |
|
| 24 |
UTItype |
| 25 |
__bswapti2 (UTItype x) |
| 26 |
{ |
| 27 |
UDItype lo, hi, outlo, outhi; |
| 28 |
lo = (UDItype) x; |
| 29 |
hi = (UDItype) (x >> 64); |
| 30 |
outhi = (lo >> 56) & 0xff; |
| 31 |
outhi |= ((lo >> 48) & 0xff) << 8; |
| 32 |
outhi |= ((lo >> 40) & 0xff) << 16; |
| 33 |
outhi |= ((lo >> 32) & 0xff) << 24; |
| 34 |
outhi |= ((lo >> 24) & 0xff) << 32; |
| 35 |
outhi |= ((lo >> 16) & 0xff) << 40; |
| 36 |
outhi |= ((lo >> 8) & 0xff) << 48; |
| 37 |
outhi |= (lo & 0xff) << 56; |
| 38 |
outlo = (hi >> 56) & 0xff; |
| 39 |
outlo |= ((hi >> 48) & 0xff) << 8; |
| 40 |
outlo |= ((hi >> 40) & 0xff) << 16; |
| 41 |
outlo |= ((hi >> 32) & 0xff) << 24; |
| 42 |
outlo |= ((hi >> 24) & 0xff) << 32; |
| 43 |
outlo |= ((hi >> 16) & 0xff) << 40; |
| 44 |
outlo |= ((hi >> 8) & 0xff) << 48; |
| 45 |
outlo |= (hi & 0xff) << 56; |
| 46 |
return ((UTItype) outhi << 64) | outlo; |
| 47 |
} |