1 /* vi: set sw=4 ts=4: */
3 Copyright 2006, Bernhard Fischer
5 Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
10 /* Convenience macros to test the version of gcc. */
12 #if defined __GNUC__ && defined __GNUC_MINOR__
13 # define __GNUC_PREREQ(maj, min) \
14 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
16 # define __GNUC_PREREQ(maj, min) 0
19 /* __restrict is known in EGCS 1.2 and above. */
20 #if !__GNUC_PREREQ (2,92)
22 # define __restrict /* Ignore */
26 /* Define macros for some gcc attributes. This permits us to use the
27 macros freely, and know that they will come into play for the
28 version of gcc in which they are supported. */
30 #if !__GNUC_PREREQ (2,7)
31 # ifndef __attribute__
32 # define __attribute__(x)
36 #ifndef ATTRIBUTE_UNUSED
37 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
38 #endif /* ATTRIBUTE_UNUSED */
40 #ifndef ATTRIBUTE_NORETURN
41 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
42 #endif /* ATTRIBUTE_NORETURN */
44 #ifndef ATTRIBUTE_PACKED
45 # define ATTRIBUTE_PACKED __attribute__ ((__packed__))
46 #endif /* ATTRIBUTE_PACKED */
48 #ifndef ATTRIBUTE_ALIGNED
49 # define ATTRIBUTE_ALIGNED(m) __attribute__ ((__aligned__(m)))
50 #endif /* ATTRIBUTE_ALIGNED */
52 /* -fwhole-program makes all symbols local. The attribute externally_visible
53 forces a symbol global. */
54 #ifndef ATTRIBUTE_EXTERNALLY_VISIBLE
55 # if __GNUC_PREREQ (4,1)
56 # define ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((__externally_visible__))
58 # define ATTRIBUTE_EXTERNALLY_VISIBLE
59 # endif /* GNUC >= 4.1 */
60 #endif /* ATTRIBUTE_EXTERNALLY_VISIBLE */
62 /* We use __extension__ in some places to suppress -pedantic warnings
63 about GCC extensions. This feature didn't work properly before
65 #if !__GNUC_PREREQ (2,8)
66 # ifndef __extension__
67 # define __extension__
71 /* ---- Endian Detection ------------------------------------ */
73 # include <byteswap.h>
78 # define BB_BIG_ENDIAN 1
79 # define BB_LITTLE_ENDIAN 0
80 #elif __BYTE_ORDER == __BIG_ENDIAN
81 # define BB_BIG_ENDIAN 1
82 # define BB_LITTLE_ENDIAN 0
84 # define BB_BIG_ENDIAN 0
85 # define BB_LITTLE_ENDIAN 1
88 /* ---- Networking ------------------------------------------ */
90 # include <arpa/inet.h>
92 # include <netinet/in.h>
95 /*----- Kernel versioning ------------------------------------*/
97 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
99 #error implement KERNEL_VERSION for your platform
102 /* ---- miscellaneous --------------------------------------- */
104 /* THIS SHOULD BE CLEANED OUT OF THE TREE ENTIRELY */
106 #define N_(Text) (Text)
108 #endif /* platform.h */