aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-08-09 21:45:42 +0000
committerChristian Grothoff <christian@grothoff.org>2012-08-09 21:45:42 +0000
commit7f4e9149c26051f5e4c4ef6fd56be8f1a69eebc3 (patch)
tree0980b6258de0617106b0a067bfc88c71bfacf725
parent75a7e3d593b154fb3b5a07f30550e2e68b6ea052 (diff)
downloadlibextractor-7f4e9149c26051f5e4c4ef6fd56be8f1a69eebc3.tar.gz
libextractor-7f4e9149c26051f5e4c4ef6fd56be8f1a69eebc3.zip
fixes
-rw-r--r--src/common/le_architecture.h92
1 files changed, 57 insertions, 35 deletions
diff --git a/src/common/le_architecture.h b/src/common/le_architecture.h
index e5d129f..d8f28f7 100644
--- a/src/common/le_architecture.h
+++ b/src/common/le_architecture.h
@@ -1,4 +1,27 @@
1#if !defined(LE_ARCHITECTURE_H) 1/*
2 This file is part of libextractor.
3 (C) 2002, 2003, 2004, 2009, 2012 Vidyut Samanta and Christian Grothoff
4
5 libextractor is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 libextractor is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with libextractor; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 */
20/**
21 * @file common/le_architecture.h
22 * @brief support routines and defines to deal with architecture-specific issues
23 */
24#ifndef LE_ARCHITECTURE_H
2#define LE_ARCHITECTURE_H 25#define LE_ARCHITECTURE_H
3 26
4#if WINDOWS 27#if WINDOWS
@@ -39,42 +62,40 @@
39 * Endian operations 62 * Endian operations
40 */ 63 */
41 64
42# if __BYTE_ORDER == __LITTLE_ENDIAN 65#if __BYTE_ORDER == __LITTLE_ENDIAN
43# define LE_htobe16(x) __bswap_16 (x) 66#define LE_htobe16(x) __bswap_16 (x)
44# define LE_htole16(x) (x) 67#define LE_htole16(x) (x)
45# define LE_be16toh(x) __bswap_16 (x) 68#define LE_be16toh(x) __bswap_16 (x)
46# define LE_le16toh(x) (x) 69#define LE_le16toh(x) (x)
47 70
48# define LE_htobe32(x) __bswap_32 (x) 71#define LE_htobe32(x) __bswap_32 (x)
49# define LE_htole32(x) (x) 72#define LE_htole32(x) (x)
50# define LE_be32toh(x) __bswap_32 (x) 73#define LE_be32toh(x) __bswap_32 (x)
51# define LE_le32toh(x) (x) 74#define LE_le32toh(x) (x)
52 75
53# define LE_htobe64(x) __bswap_64 (x) 76#define LE_htobe64(x) __bswap_64 (x)
54# define LE_htole64(x) (x) 77#define LE_htole64(x) (x)
55# define LE_be64toh(x) __bswap_64 (x) 78#define LE_be64toh(x) __bswap_64 (x)
56# define LE_le64toh(x) (x) 79#define LE_le64toh(x) (x)
57#endif 80#endif
58# if __BYTE_ORDER == __BIG_ENDIAN 81#if __BYTE_ORDER == __BIG_ENDIAN
59# define LE_htobe16(x) (x) 82#define LE_htobe16(x) (x)
60# define LE_htole16(x) __bswap_16 (x) 83#define LE_htole16(x) __bswap_16 (x)
61# define LE_be16toh(x) (x) 84#define LE_be16toh(x) (x)
62# define LE_le16toh(x) __bswap_16 (x) 85#define LE_le16toh(x) __bswap_16 (x)
63 86
64# define LE_htobe32(x) (x) 87#define LE_htobe32(x) (x)
65# define LE_htole32(x) __bswap_32 (x) 88#define LE_htole32(x) __bswap_32 (x)
66# define LE_be32toh(x) (x) 89#define LE_be32toh(x) (x)
67# define LE_le32toh(x) __bswap_32 (x) 90#define LE_le32toh(x) __bswap_32 (x)
68 91
69# define LE_htobe64(x) (x) 92#define LE_htobe64(x) (x)
70# define LE_htole64(x) __bswap_64 (x) 93#define LE_htole64(x) __bswap_64 (x)
71# define LE_be64toh(x) (x) 94#define LE_be64toh(x) (x)
72# define LE_le64toh(x) __bswap_64 (x) 95#define LE_le64toh(x) __bswap_64 (x)
73#endif 96#endif
74 97
75 98
76
77
78/** 99/**
79 * gcc-ism to get packed structs. 100 * gcc-ism to get packed structs.
80 */ 101 */
@@ -99,6 +120,7 @@
99 */ 120 */
100#define LE_NORETURN __attribute__((noreturn)) 121#define LE_NORETURN __attribute__((noreturn))
101 122
123#if MINGW
102#if __GNUC__ > 3 124#if __GNUC__ > 3
103/** 125/**
104 * gcc 4.x-ism to pack structures even on W32 (to be used before structs) 126 * gcc 4.x-ism to pack structures even on W32 (to be used before structs)
@@ -112,9 +134,9 @@
112 */ 134 */
113#define LE_NETWORK_STRUCT_END _Pragma("pack(pop)") 135#define LE_NETWORK_STRUCT_END _Pragma("pack(pop)")
114#else 136#else
115#ifdef __MINGW32__
116#error gcc 4.x or higher required on W32 systems 137#error gcc 4.x or higher required on W32 systems
117#endif 138#endif
139#else
118/** 140/**
119 * Good luck, LE_PACKED should suffice, but this won't work on W32 141 * Good luck, LE_PACKED should suffice, but this won't work on W32
120 */ 142 */
@@ -127,4 +149,4 @@
127#endif 149#endif
128 150
129 151
130#endif \ No newline at end of file 152#endif