Fixed newline characters throughout the code
[com/gs-lite.git] / src / lib / gscphostaux / byteswap.c
1 /* ------------------------------------------------
2  Copyright 2014 AT&T Intellectual Property
3  Licensed under the Apache License, Version 2.0 (the "License");
4  you may not use this file except in compliance with the License.
5  You may obtain a copy of the License at
6  
7  http://www.apache.org/licenses/LICENSE-2.0
8  
9  Unless required by applicable law or agreed to in writing, software
10  distributed under the License is distributed on an "AS IS" BASIS,
11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  See the License for the specific language governing permissions and
13  limitations under the License.
14  ------------------------------------------- */
15 #include "gsconfig.h"
16 #include "gstypes.h"
17
18 gs_uint16_t gscpbswap16(gs_uint16_t x){
19     return ((x << 8) & 0xff00) | ((x >> 8) & 0x00ff);
20 }
21
22 gs_uint32_t gscpbswap32(gs_uint32_t x ) {
23     return      ((x << 24) & 0xff000000 ) |
24         ((x <<  8) & 0x00ff0000 ) |
25         ((x >>  8) & 0x0000ff00 ) |
26         ((x >> 24) & 0x000000ff );
27 }
28
29
30 gs_uint64_t gscpbswap64(gs_uint64_t x) {
31     gs_uint64_t t1;
32     gs_uint64_t t2;
33     t1=x>>32;
34     t1 = gscpbswap32(t1);
35     t2=x & 0xffffffff;
36     t2 = gscpbswap32(t2);
37     x = t2<<32;
38     x = x|t1;
39     return x;
40 }