Changeset 270 for trunk/src/mesh
- Timestamp:
- Mar 3, 2006 7:37:18 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mesh/byte_order.h
r266 r270 2 2 #define __RP_BYTEORDER_H__ 3 3 4 //#include <stdio.h> 4 5 #include <string.h> 5 6 … … 19 20 // If the machine calling this function uses big endian byte order, 20 21 // bytes are flipped. 21 static void OrderCopy(const ValType & src_val, ValType&dst_val)22 static void OrderCopy(const ValType* src_val, ValType* dst_val) 22 23 { 23 unsigned char* src = (unsigned char *) &src_val;24 unsigned char* dst = (unsigned char *) &dst_val;24 unsigned char* src = (unsigned char *)src_val; 25 unsigned char* dst = (unsigned char *)dst_val; 25 26 26 27 // our software will use little endian … … 51 52 unsigned int i; 52 53 for (i=0; i<sizeof(ValType); i++) 53 memcpy((void*) &dst, (void*)&src, sizeof(ValType));54 memcpy((void*)dst, (void*)src, sizeof(ValType)); 54 55 } 55 56 }; 56 57 58 // copy an array of ValType elements 59 static void OrderCopyArray(const ValType* src_val, ValType* dst_val, int nitems) 60 { 61 for (int i=0; i < nitems; i++) 62 OrderCopy(&(src_val[i]), &(dst_val[i])); 63 }; 64 57 65 // swap bytes in place, src altered for BE machine. 58 static void Flip(ValType &src_val)66 static void Flip(ValType* src_val) 59 67 { 60 68 ValType val; 61 Copy(src_val, val);62 memcpy((void*) &src_val, (void*)&val, sizeof(ValType));69 Copy(src_val, &val); 70 memcpy((void*)src_val, (void*)&val, sizeof(ValType)); 63 71 }; 72 73 static void FlipArray(ValType* src_val, int nitems) 74 { 75 for (int i=0; i < nitems; i++) 76 Flip(&(src_val[i])); 77 } 64 78 65 79 operator ValType () const
Note: See TracChangeset
for help on using the changeset viewer.