os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/server/shared/mscutils.inl
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/server/shared/mscutils.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,117 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @internalTechnology
1.22 +
1.23 + Gets a 32-bit integer value which is in big-endian format from a byte stream.
1.24 +
1.25 + @param aPtr A pointer to a byte stream.
1.26 + @return A 32-bit long integer value in native machine format.
1.27 +
1.28 +*/
1.29 +inline TUint32 BigEndian::Get32(const TUint8 *aPtr)
1.30 + {
1.31 + return (aPtr[0]<<24) | (aPtr[1]<<16) | (aPtr[2]<<8) | aPtr[3];
1.32 + }
1.33 +
1.34 +/**
1.35 + Inserts a 32-bit value into a byte stream in big-endian format.
1.36 +
1.37 + @param aPtr A pointer to a byte stream.
1.38 + @param aVal A 32-bit long integer value in native machine format.
1.39 + */
1.40 +inline void BigEndian::Put32(TUint8 *aPtr, TUint32 aVal)
1.41 + {
1.42 + aPtr[0] = aVal >> 24;
1.43 + aPtr[1] = (aVal >> 16) & 0xff;
1.44 + aPtr[2] = (aVal >> 8) & 0xff;
1.45 + aPtr[3] = aVal & 0xff;
1.46 + }
1.47 +/**
1.48 + Gets a 16-bit value integer which is in big-endian format from a byte stream.
1.49 +
1.50 + @param aPtr A pointer to a byte stream.
1.51 + @return A 16-bit long integer value in native machine format.
1.52 + */
1.53 +inline TUint16 BigEndian::Get16(const TUint8 *aPtr)
1.54 + {
1.55 + return (aPtr[0]<<8) | aPtr[1];
1.56 + }
1.57 +/**
1.58 + Inserts a 16-bit value into a byte stream in big-endian format.
1.59 +
1.60 + @param aPtr A pointer to a byte stream.
1.61 + @param aVal A 16-bit long integer value in native machine format.
1.62 + */
1.63 +inline void BigEndian::Put16(TUint8 *aPtr, TUint16 aVal)
1.64 + {
1.65 + aPtr[0] = aVal >> 8;
1.66 + aPtr[1] = aVal & 0xff;
1.67 + }
1.68 +
1.69 +
1.70 +
1.71 +/**
1.72 + Gets a 32-bit integer value which is in little-endian format from a byte
1.73 + stream.
1.74 +
1.75 + @param aPtr A pointer to a byte stream.
1.76 + @return A 32-bit long integer value in native machine format.
1.77 + */
1.78 +inline TUint32 LittleEndian::Get32(const TUint8 *aPtr)
1.79 + {
1.80 + return (aPtr[3]<<24) | (aPtr[2]<<16) | (aPtr[1]<<8) | aPtr[0];
1.81 + }
1.82 +
1.83 +/**
1.84 + Inserts a 32-bit value into a byte stream in little-endian format.
1.85 +
1.86 + @param aPtr A pointer to a byte stream.
1.87 + @param aVal A 32-bit long integer value in native machine format.
1.88 + */
1.89 +inline void LittleEndian::Put32(TUint8 *aPtr, TUint32 aVal)
1.90 + {
1.91 + aPtr[3] = aVal >> 24;
1.92 + aPtr[2] = (aVal >> 16) & 0xff;
1.93 + aPtr[1] = (aVal >> 8) & 0xff;
1.94 + aPtr[0] = aVal & 0xff;
1.95 + }
1.96 +/**
1.97 + Gets a 16-bit value integer which is in little-endian format from a byte
1.98 + stream.
1.99 +
1.100 + @param aPtr A pointer to a byte stream.
1.101 + @return A 16-bit long integer value in native machine format.
1.102 + */
1.103 +inline TUint16 LittleEndian::Get16(const TUint8 *aPtr)
1.104 + {
1.105 + return (aPtr[1]<<8) | aPtr[0];
1.106 + }
1.107 +/**
1.108 + Inserts a 16-bit value into a byte stream in little-endian format.
1.109 +
1.110 + @param aPtr A pointer to a byte stream.
1.111 + @param aVal A 16-bit long integer value in native machine format.
1.112 + */
1.113 +inline void LittleEndian::Put16(TUint8 *aPtr, TUint16 aVal)
1.114 + {
1.115 + aPtr[1] = aVal >> 8;
1.116 + aPtr[0] = aVal & 0xff;
1.117 + }
1.118 +
1.119 +
1.120 +