| 1 | #ifndef MY_BYTEORDER_INCLUDED |
| 2 | #define MY_BYTEORDER_INCLUDED |
| 3 | |
| 4 | /* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; version 2 of the License. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with this program; if not, write to the Free Software |
| 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
| 18 | |
| 19 | |
| 20 | /* |
| 21 | Macro for reading 32-bit integer from network byte order (big-endian) |
| 22 | from an unaligned memory location. |
| 23 | */ |
| 24 | #define int4net(A) (int32) (((uint32) ((uchar) (A)[3])) | \ |
| 25 | (((uint32) ((uchar) (A)[2])) << 8) | \ |
| 26 | (((uint32) ((uchar) (A)[1])) << 16) | \ |
| 27 | (((uint32) ((uchar) (A)[0])) << 24)) |
| 28 | |
| 29 | /* |
| 30 | Function-like macros for reading and storing in machine independent |
| 31 | format (low byte first). There are 'korr' (assume 'corrector') variants |
| 32 | for integer types, but 'get' (assume 'getter') for floating point types. |
| 33 | */ |
| 34 | #if defined(__i386__) || defined(_WIN32) |
| 35 | #define MY_BYTE_ORDER_ARCH_OPTIMIZED |
| 36 | #include "byte_order_generic_x86.h" |
| 37 | #elif defined(__x86_64__) |
| 38 | #include "byte_order_generic_x86_64.h" |
| 39 | #else |
| 40 | #include "byte_order_generic.h" |
| 41 | #endif |
| 42 | |
| 43 | /* |
| 44 | Function-like macros for reading and storing in machine format from/to |
| 45 | short/long to/from some place in memory V should be a variable (not on |
| 46 | a register) and M a pointer to byte. |
| 47 | */ |
| 48 | #ifdef WORDS_BIGENDIAN |
| 49 | #include "big_endian.h" |
| 50 | #else |
| 51 | #include "little_endian.h" |
| 52 | #endif |
| 53 | |
| 54 | #endif /* MY_BYTEORDER_INCLUDED */ |
| 55 | |