X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Flib%2Fgscphostaux%2Fbyteswap.c;h=af016fc8bfe34a52fba8ccdefd657c85c01f40af;hb=refs%2Fchanges%2F56%2F4756%2F1;hp=82294ca5e73b428b89d75211b06240ad9ee31136;hpb=07495effe193ca3f73c3bf0ce417068f9ac9dcdd;p=com%2Fgs-lite.git diff --git a/src/lib/gscphostaux/byteswap.c b/src/lib/gscphostaux/byteswap.c index 82294ca..af016fc 100644 --- a/src/lib/gscphostaux/byteswap.c +++ b/src/lib/gscphostaux/byteswap.c @@ -1,40 +1,40 @@ -/* ------------------------------------------------ - Copyright 2014 AT&T Intellectual Property - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ------------------------------------------- */ -#include "gsconfig.h" -#include "gstypes.h" - -gs_uint16_t gscpbswap16(gs_uint16_t x){ - return ((x << 8) & 0xff00) | ((x >> 8) & 0x00ff); -} - -gs_uint32_t gscpbswap32(gs_uint32_t x ) { - return ((x << 24) & 0xff000000 ) | - ((x << 8) & 0x00ff0000 ) | - ((x >> 8) & 0x0000ff00 ) | - ((x >> 24) & 0x000000ff ); -} - - -gs_uint64_t gscpbswap64(gs_uint64_t x) { - gs_uint64_t t1; - gs_uint64_t t2; - t1=x>>32; - t1 = gscpbswap32(t1); - t2=x & 0xffffffff; - t2 = gscpbswap32(t2); - x = t2<<32; - x = x|t1; - return x; -} +/* ------------------------------------------------ + Copyright 2014 AT&T Intellectual Property + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ------------------------------------------- */ +#include "gsconfig.h" +#include "gstypes.h" + +gs_uint16_t gscpbswap16(gs_uint16_t x){ + return ((x << 8) & 0xff00) | ((x >> 8) & 0x00ff); +} + +gs_uint32_t gscpbswap32(gs_uint32_t x ) { + return ((x << 24) & 0xff000000 ) | + ((x << 8) & 0x00ff0000 ) | + ((x >> 8) & 0x0000ff00 ) | + ((x >> 24) & 0x000000ff ); +} + + +gs_uint64_t gscpbswap64(gs_uint64_t x) { + gs_uint64_t t1; + gs_uint64_t t2; + t1=x>>32; + t1 = gscpbswap32(t1); + t2=x & 0xffffffff; + t2 = gscpbswap32(t2); + x = t2<<32; + x = x|t1; + return x; +}