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