1321936Shselasky/* 2321936Shselasky * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved. 3321936Shselasky * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved. 4321936Shselasky * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. 5321936Shselasky * 6321936Shselasky * This software is available to you under a choice of one of two 7321936Shselasky * licenses. You may choose to be licensed under the terms of the GNU 8321936Shselasky * General Public License (GPL) Version 2, available from the file 9321936Shselasky * COPYING in the main directory of this source tree, or the 10321936Shselasky * OpenIB.org BSD license below: 11321936Shselasky * 12321936Shselasky * Redistribution and use in source and binary forms, with or 13321936Shselasky * without modification, are permitted provided that the following 14321936Shselasky * conditions are met: 15321936Shselasky * 16321936Shselasky * - Redistributions of source code must retain the above 17321936Shselasky * copyright notice, this list of conditions and the following 18321936Shselasky * disclaimer. 19321936Shselasky * 20321936Shselasky * - Redistributions in binary form must reproduce the above 21321936Shselasky * copyright notice, this list of conditions and the following 22321936Shselasky * disclaimer in the documentation and/or other materials 23321936Shselasky * provided with the distribution. 24321936Shselasky * 25321936Shselasky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26321936Shselasky * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27321936Shselasky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28321936Shselasky * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29321936Shselasky * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30321936Shselasky * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31321936Shselasky * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32321936Shselasky * SOFTWARE. 33321936Shselasky * 34321936Shselasky */ 35321936Shselasky 36321936Shselasky/* 37321936Shselasky * Abstract: 38321936Shselasky * provides byteswapping utilities. Basic functions are obtained from 39321936Shselasky * platform specific implementations from byteswap_osd.h. 40321936Shselasky */ 41321936Shselasky 42321936Shselasky#ifndef _CL_BYTESWAP_H_ 43321936Shselasky#define _CL_BYTESWAP_H_ 44321936Shselasky 45321936Shselasky#include <string.h> 46321936Shselasky#include <complib/cl_byteswap_osd.h> 47321936Shselasky 48321936Shselasky#ifdef __cplusplus 49321936Shselasky# define BEGIN_C_DECLS extern "C" { 50321936Shselasky# define END_C_DECLS } 51321936Shselasky#else /* !__cplusplus */ 52321936Shselasky# define BEGIN_C_DECLS 53321936Shselasky# define END_C_DECLS 54321936Shselasky#endif /* __cplusplus */ 55321936Shselasky 56321936ShselaskyBEGIN_C_DECLS 57321936Shselasky/****h* Component Library/Byte Swapping 58321936Shselasky* NAME 59321936Shselasky* Byte Swapping 60321936Shselasky* 61321936Shselasky* DESCRIPTION 62321936Shselasky* The byte swapping functions and macros allow swapping bytes from network 63321936Shselasky* byte order to host byte order. 64321936Shselasky* 65321936Shselasky* All data transmitted between systems should be in network byte order. 66321936Shselasky* In order to utilize such data, it must be converted to host byte order 67321936Shselasky* before use. 68321936Shselasky* 69321936Shselasky* SEE ALSO 70321936Shselasky* Functions: 71321936Shselasky* cl_ntoh16, cl_hton16, cl_ntoh32, cl_hton32, cl_ntoh64, cl_hton64, 72321936Shselasky* cl_ntoh 73321936Shselasky* 74321936Shselasky* Macros: 75321936Shselasky* CL_NTOH16, CL_HTON16, CL_NTOH32, CL_HTON32, CL_NTOH64, CL_HTON64 76321936Shselasky*********/ 77321936Shselasky/* 78321936Shselasky * The byteswap_osd.h provides the following macros. 79321936Shselasky * __LITTLE_ENDIAN 80321936Shselasky * __BIG_ENDIAN 81321936Shselasky * __BYTE_ORDER 82321936Shselasky * 83321936Shselasky * If the platform provides byte swapping functions, byteswap_osd.h also 84321936Shselasky * provides the following macros. 85321936Shselasky * ntoh16, hton16 86321936Shselasky * ntoh32, hton32 87321936Shselasky * ntoh64, hton64 88321936Shselasky */ 89321936Shselasky#ifndef __BYTE_ORDER 90321936Shselasky#error "__BYTE_ORDER macro undefined. Missing in endian.h?" 91321936Shselasky#endif 92321936Shselasky#if __BYTE_ORDER == __LITTLE_ENDIAN 93321936Shselasky#define CPU_LE 1 94321936Shselasky#define CPU_BE 0 95321936Shselasky#else 96321936Shselasky#define CPU_LE 0 97321936Shselasky#define CPU_BE 1 98321936Shselasky#endif 99321936Shselasky/****d* Component Library: Byte Swapping/CL_NTOH16 100321936Shselasky* NAME 101321936Shselasky* CL_NTOH16 102321936Shselasky* 103321936Shselasky* DESCRIPTION 104321936Shselasky* The CL_NTOH16 macro converts a 16-bit value from network byte order to 105321936Shselasky* host byte order. The CL_NTOH16 macro will cause constant values to be 106321936Shselasky* swapped by the pre-processor. For variables, CL_NTOH16 is less efficient 107321936Shselasky* than the cl_ntoh16 function. 108321936Shselasky* 109321936Shselasky* SYNOPSIS 110321936Shselasky* CL_NTOH16( val ); 111321936Shselasky* 112321936Shselasky* PARAMETERS 113321936Shselasky* val 114321936Shselasky* [in] 16-bit value to swap from network byte order to host byte order. 115321936Shselasky* 116321936Shselasky* RESULT 117321936Shselasky* Value of val converted to host byte order. 118321936Shselasky* 119321936Shselasky* NOTES 120321936Shselasky* This macro is analogous to CL_HTON16. 121321936Shselasky* 122321936Shselasky* SEE ALSO 123321936Shselasky* Byte Swapping, CL_HTON16, CL_NTOH32, CL_NTOH64, 124321936Shselasky* cl_ntoh16, cl_ntoh32, cl_ntoh64, cl_ntoh 125321936Shselasky*********/ 126321936Shselasky/****d* Component Library: Byte Swapping/CL_HTON16 127321936Shselasky* NAME 128321936Shselasky* CL_HTON16 129321936Shselasky* 130321936Shselasky* DESCRIPTION 131321936Shselasky* The CL_HTON16 macro converts a 16-bit value from host byte order to 132321936Shselasky* network byte order. The CL_HTON16 macro will cause constant values to be 133321936Shselasky* swapped by the pre-processor. For variables, CL_HTON16 is less efficient 134321936Shselasky* than the cl_hton16 function. 135321936Shselasky* 136321936Shselasky* SYNOPSIS 137321936Shselasky* CL_HTON16( val ); 138321936Shselasky* 139321936Shselasky* PARAMETERS 140321936Shselasky* val 141321936Shselasky* [in] 16-bit value to swap from host byte order to network byte order. 142321936Shselasky* 143321936Shselasky* RESULT 144321936Shselasky* Value of val converted to network byte order. 145321936Shselasky* 146321936Shselasky* NOTES 147321936Shselasky* This macro is analogous to CL_NTOH16. 148321936Shselasky* 149321936Shselasky* SEE ALSO 150321936Shselasky* Byte Swapping, CL_NTOH16, CL_HTON32, CL_HTON64, 151321936Shselasky* cl_hton16, cl_hton32, cl_hton64, cl_ntoh 152321936Shselasky*********/ 153321936Shselasky#if CPU_LE 154321936Shselasky#define CL_NTOH16( x ) (uint16_t)( \ 155321936Shselasky (((uint16_t)(x) & 0x00FF) << 8) | \ 156321936Shselasky (((uint16_t)(x) & 0xFF00) >> 8) ) 157321936Shselasky#else 158321936Shselasky#define CL_NTOH16( x ) (x) 159321936Shselasky#endif 160321936Shselasky#define CL_HTON16 CL_NTOH16 161321936Shselasky/****f* Component Library: Byte Swapping/cl_ntoh16 162321936Shselasky* NAME 163321936Shselasky* cl_ntoh16 164321936Shselasky* 165321936Shselasky* DESCRIPTION 166321936Shselasky* The cl_ntoh16 function converts a 16-bit value from network byte order to 167321936Shselasky* host byte order. 168321936Shselasky* 169321936Shselasky* SYNOPSIS 170321936Shselasky* uint16_t 171321936Shselasky* cl_ntoh16( 172321936Shselasky* IN const uint16_t val ); 173321936Shselasky* 174321936Shselasky* PARAMETERS 175321936Shselasky* val 176321936Shselasky* [in] Value to swap from network byte order to host byte order. 177321936Shselasky* 178321936Shselasky* RETURN VALUE 179321936Shselasky* Value of val converted to host byte order. 180321936Shselasky* 181321936Shselasky* NOTES 182321936Shselasky* This function is analogous to cl_hton16. 183321936Shselasky* 184321936Shselasky* SEE ALSO 185321936Shselasky* Byte Swapping, cl_hton16, cl_ntoh32, cl_ntoh64, cl_ntoh 186321936Shselasky*********/ 187321936Shselasky/****f* Component Library: Byte Swapping/cl_hton16 188321936Shselasky* NAME 189321936Shselasky* cl_hton16 190321936Shselasky* 191321936Shselasky* DESCRIPTION 192321936Shselasky* The cl_hton16 function converts a 16-bit value from host byte order to 193321936Shselasky* network byte order. 194321936Shselasky* 195321936Shselasky* SYNOPSIS 196321936Shselasky* uint16_t 197321936Shselasky* cl_hton16( 198321936Shselasky* IN const uint16_t val ); 199321936Shselasky* 200321936Shselasky* PARAMETERS 201321936Shselasky* val 202321936Shselasky* [in] Value to swap from host byte order to network byte order . 203321936Shselasky* 204321936Shselasky* RETURN VALUE 205321936Shselasky* Value of val converted to network byte order. 206321936Shselasky* 207321936Shselasky* NOTES 208321936Shselasky* This function is analogous to cl_ntoh16. 209321936Shselasky* 210321936Shselasky* SEE ALSO 211321936Shselasky* Byte Swapping, cl_ntoh16, cl_hton32, cl_hton64, cl_ntoh 212321936Shselasky*********/ 213321936Shselasky#ifndef cl_ntoh16 214321936Shselasky#define cl_ntoh16 CL_NTOH16 215321936Shselasky#define cl_hton16 CL_HTON16 216321936Shselasky#endif 217321936Shselasky/****d* Component Library: Byte Swapping/CL_NTOH32 218321936Shselasky* NAME 219321936Shselasky* CL_NTOH32 220321936Shselasky* 221321936Shselasky* DESCRIPTION 222321936Shselasky* The CL_NTOH32 macro converts a 32-bit value from network byte order to 223321936Shselasky* host byte order. The CL_NTOH32 macro will cause constant values to be 224321936Shselasky* swapped by the pre-processor. For variables, CL_NTOH32 is less efficient 225321936Shselasky* than the cl_ntoh32 function. 226321936Shselasky* 227321936Shselasky* SYNOPSIS 228321936Shselasky* CL_NTOH32( val ); 229321936Shselasky* 230321936Shselasky* PARAMETERS 231321936Shselasky* val 232321936Shselasky* [in] 32-bit value to swap from network byte order to host byte order. 233321936Shselasky* 234321936Shselasky* RESULT 235321936Shselasky* Value of val converted to host byte order. 236321936Shselasky* 237321936Shselasky* NOTES 238321936Shselasky* This macro is analogous to CL_HTON32. 239321936Shselasky* 240321936Shselasky* SEE ALSO 241321936Shselasky* Byte Swapping, CL_HTON32, CL_NTOH16, CL_NTOH64, 242321936Shselasky* cl_ntoh16, cl_ntoh32, cl_ntoh64, cl_ntoh 243321936Shselasky*********/ 244321936Shselasky/****d* Component Library: Byte Swapping/CL_HTON32 245321936Shselasky* NAME 246321936Shselasky* CL_HTON32 247321936Shselasky* 248321936Shselasky* DESCRIPTION 249321936Shselasky* The CL_HTON32 macro converts a 32-bit value from host byte order to 250321936Shselasky* network byte order. The CL_HTON32 macro will cause constant values to be 251321936Shselasky* swapped by the pre-processor. For variables, CL_HTON32 is less efficient 252321936Shselasky* than the cl_hton32 function. 253321936Shselasky* 254321936Shselasky* SYNOPSIS 255321936Shselasky* CL_HTON32( val ); 256321936Shselasky* 257321936Shselasky* PARAMETERS 258321936Shselasky* val 259321936Shselasky* [in] 32-bit value to swap from host byte order to network byte order. 260321936Shselasky* 261321936Shselasky* RESULT 262321936Shselasky* Value of val converted to network byte order. 263321936Shselasky* 264321936Shselasky* NOTES 265321936Shselasky* This macro is analogous to CL_NTOH32. 266321936Shselasky* 267321936Shselasky* SEE ALSO 268321936Shselasky* Byte Swapping, CL_NTOH32, CL_HTON16, CL_HTON64, 269321936Shselasky* cl_hton16, cl_hton32, cl_hton64, cl_ntoh 270321936Shselasky*********/ 271321936Shselasky#if CPU_LE 272321936Shselasky#define CL_NTOH32( x ) (uint32_t)( \ 273321936Shselasky (((uint32_t)(x) & 0x000000FF) << 24) | \ 274321936Shselasky (((uint32_t)(x) & 0x0000FF00) << 8) | \ 275321936Shselasky (((uint32_t)(x) & 0x00FF0000) >> 8) | \ 276321936Shselasky (((uint32_t)(x) & 0xFF000000) >> 24) ) 277321936Shselasky#else 278321936Shselasky#define CL_NTOH32( x ) (x) 279321936Shselasky#endif 280321936Shselasky#define CL_HTON32 CL_NTOH32 281321936Shselasky/****f* Component Library: Byte Swapping/cl_ntoh32 282321936Shselasky* NAME 283321936Shselasky* cl_ntoh32 284321936Shselasky* 285321936Shselasky* DESCRIPTION 286321936Shselasky* The cl_ntoh32 function converts a 32-bit value from network byte order to 287321936Shselasky* host byte order. 288321936Shselasky* 289321936Shselasky* SYNOPSIS 290321936Shselasky* uint32_t 291321936Shselasky* cl_ntoh32( 292321936Shselasky* IN const uint32_t val ); 293321936Shselasky* 294321936Shselasky* PARAMETERS 295321936Shselasky* val 296321936Shselasky* [in] Value to swap from network byte order to host byte order. 297321936Shselasky* 298321936Shselasky* RETURN VALUE 299321936Shselasky* Value of val converted in host byte order. 300321936Shselasky* 301321936Shselasky* NOTES 302321936Shselasky* This function is analogous to cl_hton32. 303321936Shselasky* 304321936Shselasky* SEE ALSO 305321936Shselasky* Byte Swapping, cl_hton32, cl_ntoh16, cl_ntoh64, cl_ntoh 306321936Shselasky*********/ 307321936Shselasky/****f* Component Library: Byte Swapping/cl_hton32 308321936Shselasky* NAME 309321936Shselasky* cl_hton32 310321936Shselasky* 311321936Shselasky* DESCRIPTION 312321936Shselasky* The cl_hton32 function converts a 32-bit value from host byte order to 313321936Shselasky* network byte order. 314321936Shselasky* 315321936Shselasky* SYNOPSIS 316321936Shselasky* uint32_t 317321936Shselasky* cl_hton32( 318321936Shselasky* IN const uint32_t val ); 319321936Shselasky* 320321936Shselasky* PARAMETERS 321321936Shselasky* val 322321936Shselasky* [in] Value to swap from host byte order to network byte order . 323321936Shselasky* 324321936Shselasky* RETURN VALUE 325321936Shselasky* Value of val converted to network byte order. 326321936Shselasky* 327321936Shselasky* NOTES 328321936Shselasky* This function is analogous to cl_ntoh32. 329321936Shselasky* 330321936Shselasky* SEE ALSO 331321936Shselasky* Byte Swapping, cl_ntoh32, cl_hton16, cl_hton64, cl_ntoh 332321936Shselasky*********/ 333321936Shselasky#ifndef cl_ntoh32 334321936Shselasky#define cl_ntoh32 CL_NTOH32 335321936Shselasky#define cl_hton32 CL_HTON32 336321936Shselasky#endif 337321936Shselasky/****d* Component Library: Byte Swapping/CL_NTOH64 338321936Shselasky* NAME 339321936Shselasky* CL_NTOH64 340321936Shselasky* 341321936Shselasky* DESCRIPTION 342321936Shselasky* The CL_NTOH64 macro converts a 64-bit value from network byte order to 343321936Shselasky* host byte order. The CL_NTOH64 macro will cause constant values to be 344321936Shselasky* swapped by the pre-processor. For variables, CL_NTOH64 is less efficient 345321936Shselasky* than the cl_ntoh64 function. 346321936Shselasky* 347321936Shselasky* SYNOPSIS 348321936Shselasky* CL_NTOH64( val ); 349321936Shselasky* 350321936Shselasky* PARAMETERS 351321936Shselasky* val 352321936Shselasky* [in] 64-bit value to swap from network byte order to host byte order. 353321936Shselasky* 354321936Shselasky* RESULT 355321936Shselasky* Value of val converted to host byte order. 356321936Shselasky* 357321936Shselasky* NOTES 358321936Shselasky* This macro is analogous to CL_HTON64. 359321936Shselasky* 360321936Shselasky* SEE ALSO 361321936Shselasky* Byte Swapping, CL_HTON64, CL_NTOH16, CL_NTOH32, 362321936Shselasky* cl_ntoh16, cl_ntoh32, cl_ntoh64, cl_ntoh 363321936Shselasky*********/ 364321936Shselasky/****d* Component Library: Byte Swapping/CL_HTON64 365321936Shselasky* NAME 366321936Shselasky* CL_HTON64 367321936Shselasky* 368321936Shselasky* DESCRIPTION 369321936Shselasky* The CL_HTON64 macro converts a 64-bit value from host byte order to 370321936Shselasky* network byte order. The CL_HTON64 macro will cause constant values to be 371321936Shselasky* swapped by the pre-processor. For variables, CL_HTON64 is less efficient 372321936Shselasky* than the cl_hton64 function. 373321936Shselasky* 374321936Shselasky* SYNOPSIS 375321936Shselasky* CL_HTON64( val ); 376321936Shselasky* 377321936Shselasky* PARAMETERS 378321936Shselasky* val 379321936Shselasky* [in] 64-bit value to swap from host byte order to network byte order. 380321936Shselasky* 381321936Shselasky* RESULT 382321936Shselasky* Value of val converted to network byte order. 383321936Shselasky* 384321936Shselasky* NOTES 385321936Shselasky* This macro is analogous to CL_NTOH64. 386321936Shselasky* 387321936Shselasky* SEE ALSO 388321936Shselasky* Byte Swapping, CL_NTOH64, CL_HTON16, CL_HTON32, 389321936Shselasky* cl_hton16, cl_hton32, cl_hton64, cl_ntoh 390321936Shselasky*********/ 391321936Shselasky#if CPU_LE 392321936Shselasky#define CL_NTOH64( x ) (uint64_t)( \ 393321936Shselasky (((uint64_t)(x) & 0x00000000000000FFULL) << 56) | \ 394321936Shselasky (((uint64_t)(x) & 0x000000000000FF00ULL) << 40) | \ 395321936Shselasky (((uint64_t)(x) & 0x0000000000FF0000ULL) << 24) | \ 396321936Shselasky (((uint64_t)(x) & 0x00000000FF000000ULL) << 8 ) | \ 397321936Shselasky (((uint64_t)(x) & 0x000000FF00000000ULL) >> 8 ) | \ 398321936Shselasky (((uint64_t)(x) & 0x0000FF0000000000ULL) >> 24) | \ 399321936Shselasky (((uint64_t)(x) & 0x00FF000000000000ULL) >> 40) | \ 400321936Shselasky (((uint64_t)(x) & 0xFF00000000000000ULL) >> 56) ) 401321936Shselasky#else 402321936Shselasky#define CL_NTOH64( x ) (x) 403321936Shselasky#endif 404321936Shselasky#define CL_HTON64 CL_NTOH64 405321936Shselasky/****f* Component Library: Byte Swapping/cl_ntoh64 406321936Shselasky* NAME 407321936Shselasky* cl_ntoh64 408321936Shselasky* 409321936Shselasky* DESCRIPTION 410321936Shselasky* The cl_ntoh64 function converts a 64-bit value from network byte order to 411321936Shselasky* host byte order. 412321936Shselasky* 413321936Shselasky* SYNOPSIS 414321936Shselasky* uint64_t 415321936Shselasky* cl_ntoh64( 416321936Shselasky* IN const uint64_t val ); 417321936Shselasky* 418321936Shselasky* PARAMETERS 419321936Shselasky* val 420321936Shselasky* [in] Value to swap from network byte order to host byte order. 421321936Shselasky* 422321936Shselasky* RETURN VALUE 423321936Shselasky* Value of val converted in host byte order. 424321936Shselasky* 425321936Shselasky* NOTES 426321936Shselasky* This function is analogous to cl_hton64. 427321936Shselasky* 428321936Shselasky* SEE ALSO 429321936Shselasky* Byte Swapping, cl_hton64, cl_ntoh16, cl_ntoh32, cl_ntoh 430321936Shselasky*********/ 431321936Shselasky/****f* Component Library: Byte Swapping/cl_hton64 432321936Shselasky* NAME 433321936Shselasky* cl_hton64 434321936Shselasky* 435321936Shselasky* DESCRIPTION 436321936Shselasky* The cl_hton64 function converts a 64-bit value from host byte order to 437321936Shselasky* network byte order. 438321936Shselasky* 439321936Shselasky* SYNOPSIS 440321936Shselasky* uint64_t 441321936Shselasky* cl_hton64( 442321936Shselasky* IN const uint64_t val ); 443321936Shselasky* 444321936Shselasky* PARAMETERS 445321936Shselasky* val 446321936Shselasky* [in] Value to swap from host byte order to network byte order . 447321936Shselasky* 448321936Shselasky* RETURN VALUE 449321936Shselasky* Value of val converted to network byte order. 450321936Shselasky* 451321936Shselasky* NOTES 452321936Shselasky* This function is analogous to cl_ntoh64. 453321936Shselasky* 454321936Shselasky* SEE ALSO 455321936Shselasky* Byte Swapping, cl_ntoh64, cl_hton16, cl_hton32, cl_ntoh 456321936Shselasky*********/ 457321936Shselasky#ifndef cl_ntoh64 458321936Shselasky#define cl_ntoh64 CL_NTOH64 459321936Shselasky#define cl_hton64 CL_HTON64 460321936Shselasky#endif 461321936Shselasky/****f* Component Library: Byte Swapping/cl_ntoh 462321936Shselasky* NAME 463321936Shselasky* cl_ntoh 464321936Shselasky* 465321936Shselasky* DESCRIPTION 466321936Shselasky* The cl_ntoh function converts a value from network byte order to 467321936Shselasky* host byte order. 468321936Shselasky* 469321936Shselasky* SYNOPSIS 470321936Shselasky*/ 471321936Shselaskystatic inline void 472321936Shselaskycl_ntoh(OUT char *const p_dest, 473321936Shselasky IN const char *const p_src, IN const uint8_t size) 474321936Shselasky{ 475321936Shselasky#if CPU_LE 476321936Shselasky uint8_t i; 477321936Shselasky char temp; 478321936Shselasky 479321936Shselasky if (p_src == p_dest) { 480321936Shselasky /* Swap in place if source and destination are the same. */ 481321936Shselasky for (i = 0; i < size / 2; i++) { 482321936Shselasky temp = p_dest[i]; 483321936Shselasky p_dest[i] = p_src[size - 1 - i]; 484321936Shselasky p_dest[size - 1 - i] = temp; 485321936Shselasky } 486321936Shselasky } else { 487321936Shselasky for (i = 0; i < size; i++) 488321936Shselasky p_dest[i] = p_src[size - 1 - i]; 489321936Shselasky } 490321936Shselasky#else 491321936Shselasky /* 492321936Shselasky * If the source and destination are not the same, copy the source to 493321936Shselasky * the destination. 494321936Shselasky */ 495321936Shselasky if (p_src != p_dest) 496321936Shselasky memcpy(p_dest, p_src, size); 497321936Shselasky#endif 498321936Shselasky} 499321936Shselasky 500321936Shselasky/* 501321936Shselasky* PARAMETERS 502321936Shselasky* p_dest 503321936Shselasky* [in] Pointer to a byte array to contain the converted value of p_src. 504321936Shselasky* 505321936Shselasky* p_src 506321936Shselasky* [in] Pointer to a byte array to be converted from network byte 507321936Shselasky* ordering. 508321936Shselasky* 509321936Shselasky* size 510321936Shselasky* [in] Number of bytes to swap.p_dest 511321936Shselasky* 512321936Shselasky* RETURN VALUE 513321936Shselasky* This function does not return a value. 514321936Shselasky* 515321936Shselasky* NOTES 516321936Shselasky* cl_ntoh can perform in place swapping if both p_src and p_dest point to 517321936Shselasky* the same buffer. 518321936Shselasky* 519321936Shselasky* SEE ALSO 520321936Shselasky* Byte Swapping, cl_ntoh16, cl_ntoh32, cl_ntoh64 521321936Shselasky*********/ 522321936Shselasky 523321936ShselaskyEND_C_DECLS 524321936Shselasky#endif /* _CL_BYTESWAP_H_ */ 525