2 Copyright 2006, Bernhard Fischer
4 Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
9 /* Convenience macros to test the version of gcc. */
11 #if defined __GNUC__ && defined __GNUC_MINOR__
12 # define __GNUC_PREREQ(maj, min) \
13 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
15 # define __GNUC_PREREQ(maj, min) 0
18 /* __restrict is known in EGCS 1.2 and above. */
19 #if !__GNUC_PREREQ (2,92)
21 # define __restrict /* Ignore */
25 /* Define macros for some gcc attributes. This permits us to use the
26 macros freely, and know that they will come into play for the
27 version of gcc in which they are supported. */
29 #if !__GNUC_PREREQ (2,7)
30 # ifndef __attribute__
31 # define __attribute__(x)
35 #ifndef ATTRIBUTE_UNUSED
36 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
37 #endif /* ATTRIBUTE_UNUSED */
39 #ifndef ATTRIBUTE_NORETURN
40 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
41 #endif /* ATTRIBUTE_NORETURN */
43 #ifndef ATTRIBUTE_PACKED
44 # define ATTRIBUTE_PACKED __attribute__ ((__packed__))
45 #endif /* ATTRIBUTE_PACKED */
47 #ifndef ATTRIBUTE_ALIGNED
48 # define ATTRIBUTE_ALIGNED(m) __attribute__ ((__aligned__(m)))
49 #endif /* ATTRIBUTE_ALIGNED */
51 /* -fwhole-program makes all symbols local. The attribute externally_visible
52 forces a symbol global. */
53 #ifndef ATTRIBUTE_EXTERNALLY_VISIBLE
54 # if __GNUC_PREREQ (4,1)
55 # define ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((__externally_visible__))
57 # define ATTRIBUTE_EXTERNALLY_VISIBLE
58 # endif /* GNUC >= 4.1 */
59 #endif /* ATTRIBUTE_EXTERNALLY_VISIBLE */
61 /* We use __extension__ in some places to suppress -pedantic warnings
62 about GCC extensions. This feature didn't work properly before
64 #if !__GNUC_PREREQ (2,8)
65 # ifndef __extension__
66 # define __extension__
70 /* ---- Endian Detection ------------------------------------ */
72 # include <byteswap.h>
77 # define BB_BIG_ENDIAN 1
78 # define BB_LITTLE_ENDIAN 0
79 #elif __BYTE_ORDER == __BIG_ENDIAN
80 # define BB_BIG_ENDIAN 1
81 # define BB_LITTLE_ENDIAN 0
83 # define BB_BIG_ENDIAN 0
84 # define BB_LITTLE_ENDIAN 1
87 /* ---- Networking ------------------------------------------ */
89 # include <arpa/inet.h>
91 # include <netinet/in.h>
94 /*----- Kernel versioning ------------------------------------*/
96 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
98 #error implement KERNEL_VERSION for your platform
101 /* ---- miscellaneous --------------------------------------- */
103 /* THIS SHOULD BE CLEANED OUT OF THE TREE ENTIRELY */
105 #define N_(Text) (Text)
107 #endif /* platform.h */