Annotation of truecrypt/common/endian.h, revision 1.1.1.14

1.1.1.10  root        1: /*
1.1.1.12  root        2:  Legal Notice: Some portions of the source code contained in this file were
                      3:  derived from the source code of Encryption for the Masses 2.02a, which is
                      4:  Copyright (c) 1998-2000 Paul Le Roux and which is governed by the 'License
                      5:  Agreement for Encryption for the Masses'. Modifications and additions to
                      6:  the original source code (contained in this file) and all other portions of
                      7:  this file are Copyright (c) 2003-2008 TrueCrypt Foundation and are governed
1.1.1.14! root        8:  by the TrueCrypt License 2.5 the full text of which is contained in the
1.1.1.12  root        9:  file License.txt included in TrueCrypt binary and source code distribution
1.1.1.10  root       10:  packages. */
1.1.1.6   root       11: 
1.1.1.8   root       12: #ifndef TC_ENDIAN_H
                     13: #define TC_ENDIAN_H
                     14: 
1.1.1.12  root       15: #if defined(__cplusplus)
                     16: extern "C"
                     17: {
                     18: #endif
                     19: 
1.1.1.6   root       20: #ifdef _WIN32
                     21: 
                     22: #      ifndef LITTLE_ENDIAN
                     23: #              define LITTLE_ENDIAN 1234
                     24: #      endif
                     25: #      ifndef BYTE_ORDER
                     26: #              define BYTE_ORDER LITTLE_ENDIAN
                     27: #      endif
                     28: 
                     29: #elif !defined(BYTE_ORDER)
                     30: 
1.1.1.13  root       31: #      ifdef TC_MACOSX
                     32: #              include <machine/endian.h>
                     33: #      elif defined (TC_BSD)
                     34: #              include <sys/endian.h>
1.1.1.10  root       35: #      else
1.1.1.13  root       36: #              include <endian.h>
                     37: #      endif
1.1.1.6   root       38: 
1.1.1.13  root       39: #      ifndef BYTE_ORDER
                     40: #              ifndef __BYTE_ORDER
                     41: #                      error Byte order cannot be determined (BYTE_ORDER undefined)
1.1.1.10  root       42: #              endif
1.1.1.6   root       43: 
1.1.1.13  root       44: #              define BYTE_ORDER __BYTE_ORDER
                     45: #      endif
1.1.1.6   root       46: 
1.1.1.13  root       47: #      ifndef LITTLE_ENDIAN
                     48: #              define LITTLE_ENDIAN __LITTLE_ENDIAN
                     49: #      endif
                     50: 
                     51: #      ifndef BIG_ENDIAN
                     52: #              define BIG_ENDIAN __BIG_ENDIAN
1.1.1.10  root       53: #      endif
1.1.1.4   root       54: 
1.1.1.6   root       55: #endif // !BYTE_ORDER
1.1.1.4   root       56: 
                     57: /* Macros to read and write 16, 32, and 64-bit quantities in a portable manner.
                     58:    These functions are implemented as macros rather than true functions as
                     59:    the need to adjust the memory pointers makes them somewhat painful to call
                     60:    in user code */
                     61: 
                     62: #define mputInt64(memPtr,data) \
                     63:        *memPtr++ = ( unsigned char ) ( ( ( data ) >> 56 ) & 0xFF ), \
                     64:        *memPtr++ = ( unsigned char ) ( ( ( data ) >> 48 ) & 0xFF ), \
                     65:        *memPtr++ = ( unsigned char ) ( ( ( data ) >> 40 ) & 0xFF ), \
                     66:        *memPtr++ = ( unsigned char ) ( ( ( data ) >> 32 ) & 0xFF ), \
                     67:        *memPtr++ = ( unsigned char ) ( ( ( data ) >> 24 ) & 0xFF ), \
                     68:        *memPtr++ = ( unsigned char ) ( ( ( data ) >> 16 ) & 0xFF ), \
                     69:        *memPtr++ = ( unsigned char ) ( ( ( data ) >> 8 ) & 0xFF ), \
                     70:        *memPtr++ = ( unsigned char ) ( ( data ) & 0xFF )
                     71: 
1.1       root       72: #define mputLong(memPtr,data) \
                     73:        *memPtr++ = ( unsigned char ) ( ( ( data ) >> 24 ) & 0xFF ), \
                     74:        *memPtr++ = ( unsigned char ) ( ( ( data ) >> 16 ) & 0xFF ), \
                     75:        *memPtr++ = ( unsigned char ) ( ( ( data ) >> 8 ) & 0xFF ), \
                     76:        *memPtr++ = ( unsigned char ) ( ( data ) & 0xFF )
                     77: 
                     78: #define mputWord(memPtr,data) \
                     79:        *memPtr++ = ( unsigned char ) ( ( ( data ) >> 8 ) & 0xFF ), \
                     80:        *memPtr++ = ( unsigned char ) ( ( data ) & 0xFF )
                     81: 
                     82: #define mputByte(memPtr,data)  \
                     83:        *memPtr++ = ( unsigned char ) data
                     84: 
                     85: #define mputBytes(memPtr,data,len)  \
                     86:        memcpy (memPtr,data,len); \
                     87:        memPtr += len;
                     88: 
1.1.1.4   root       89: #define mgetInt64(memPtr)              \
                     90:        ( memPtr += 8, ( ( unsigned __int64 ) memPtr[ -8 ] << 56 ) | ( ( unsigned __int64 ) memPtr[ -7 ] << 48 ) | \
                     91:        ( ( unsigned __int64 ) memPtr[ -6 ] << 40 ) | ( ( unsigned __int64 ) memPtr[ -5 ] << 32 ) | \
                     92:        ( ( unsigned __int64 ) memPtr[ -4 ] << 24 ) | ( ( unsigned __int64 ) memPtr[ -3 ] << 16 ) | \
                     93:          ( ( unsigned __int64 ) memPtr[ -2 ] << 8 ) | ( unsigned __int64 ) memPtr[ -1 ] )
                     94: 
1.1       root       95: #define mgetLong(memPtr)               \
1.1.1.6   root       96:        ( memPtr += 4, ( ( unsigned __int32 ) memPtr[ -4 ] << 24 ) | ( ( unsigned __int32 ) memPtr[ -3 ] << 16 ) | \
                     97:          ( ( unsigned __int32 ) memPtr[ -2 ] << 8 ) | ( unsigned __int32 ) memPtr[ -1 ] )
1.1       root       98: 
                     99: #define mgetWord(memPtr)               \
                    100:        ( memPtr += 2, ( unsigned short ) memPtr[ -2 ] << 8 ) | ( ( unsigned short ) memPtr[ -1 ] ) 
                    101: 
                    102: #define mgetByte(memPtr)               \
                    103:        ( ( unsigned char ) *memPtr++ )
                    104: 
1.1.1.6   root      105: #if BYTE_ORDER == BIG_ENDIAN
1.1.1.10  root      106: #      define LE16(x) MirrorBytes16(x)
1.1.1.6   root      107: #      define LE32(x) MirrorBytes32(x)
                    108: #      define LE64(x) MirrorBytes64(x)
                    109: #else
1.1.1.10  root      110: #      define LE16(x) (x)
1.1.1.6   root      111: #      define LE32(x) (x)
                    112: #      define LE64(x) (x)
                    113: #endif
                    114: 
1.1.1.7   root      115: #if BYTE_ORDER == LITTLE_ENDIAN
1.1.1.10  root      116: #      define BE16(x) MirrorBytes16(x)
1.1.1.7   root      117: #      define BE32(x) MirrorBytes32(x)
                    118: #      define BE64(x) MirrorBytes64(x)
                    119: #else
1.1.1.10  root      120: #      define BE16(x) (x)
1.1.1.7   root      121: #      define BE32(x) (x)
                    122: #      define BE64(x) (x)
                    123: #endif
                    124: 
1.1.1.10  root      125: unsigned __int16 MirrorBytes16 (unsigned __int16 x);
1.1.1.6   root      126: unsigned __int32 MirrorBytes32 (unsigned __int32 x);
1.1.1.12  root      127: #ifndef TC_NO_COMPILER_INT64
1.1.1.6   root      128: unsigned __int64 MirrorBytes64 (unsigned __int64 x);
1.1.1.12  root      129: #endif 
1.1.1.6   root      130: void LongReverse ( unsigned __int32 *buffer , unsigned byteCount );
1.1.1.8   root      131: 
1.1.1.12  root      132: #if defined(__cplusplus)
                    133: }
                    134: #endif
                    135: 
1.1.1.8   root      136: #endif /* TC_ENDIAN_H */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.