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

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