1/* Copyright (C) 2021-2022 Free Software Foundation, Inc.
2
3This file is free software; you can redistribute it and/or modify it
4under the terms of the GNU General Public License as published by the
5Free Software Foundation; either version 3, or (at your option) any
6later version.
7
8This file is distributed in the hope that it will be useful, but
9WITHOUT ANY WARRANTY; without even the implied warranty of
10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11General Public License for more details.
12
13Under Section 7 of GPL version 3, you are granted additional
14permissions described in the GCC Runtime Library Exception, version
153.1, as published by the Free Software Foundation.
16
17You should have received a copy of the GNU General Public License and
18a copy of the GCC Runtime Library Exception along with this program;
19see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
20<http://www.gnu.org/licenses/>.  */
21
22#include "lib2-gcn.h"
23
24UTItype
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}
48