blob: 68c7abbc6bdfd3ff2812248021225176a8385eaa [file] [log] [blame]
Bernhard Reutner-Fischer86f5c992006-01-22 22:55:11 +00001/*
2 Copyright 2006, Bernhard Fischer
3
4 Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
5*/
6#ifndef __PLATFORM_H
7#define __PLATFORM_H 1
8
9/* Convenience macros to test the version of gcc. */
10#undef __GNUC_PREREQ
11#if defined __GNUC__ && defined __GNUC_MINOR__
12# define __GNUC_PREREQ(maj, min) \
13 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
14#else
15# define __GNUC_PREREQ(maj, min) 0
16#endif
17
18/* __restrict is known in EGCS 1.2 and above. */
19#if !__GNUC_PREREQ (2,92)
20# ifndef __restrict
21# define __restrict /* Ignore */
22# endif
23#endif
24
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. */
28
29#if !__GNUC_PREREQ (2,7)
30# ifndef __attribute__
31# define __attribute__(x)
32# endif
33#endif
34
35#if 0
36/* Attribute __malloc__ on functions was valid as of gcc 2.96. */
37#ifndef ATTRIBUTE_MALLOC
38# if __GNUC_PREREQ (2,96)
39# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
40# else
41# define ATTRIBUTE_MALLOC
42# endif /* GNUC >= 2.96 */
43#endif /* ATTRIBUTE_MALLOC */
44#endif
45
46#ifndef ATTRIBUTE_UNUSED
47#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
48#endif /* ATTRIBUTE_UNUSED */
49
50#ifndef ATTRIBUTE_NORETURN
51#define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
52#endif /* ATTRIBUTE_NORETURN */
53
54#ifndef ATTRIBUTE_PACKED
55#define ATTRIBUTE_PACKED __attribute__ ((__packed__))
56#endif /* ATTRIBUTE_NORETURN */
57
Bernhard Reutner-Fischer9f4a1e12006-01-31 09:53:53 +000058#ifndef ATTRIBUTE_ALIGNED
59#define ATTRIBUTE_ALIGNED(m) __attribute__ ((__aligned__(m)))
60#endif /* ATTRIBUTE_ALIGNED */
61
Bernhard Reutner-Fischer86f5c992006-01-22 22:55:11 +000062/* -fwhole-program makes all symbols local. The attribute externally_visible
63 forces a symbol global. */
64#ifndef ATTRIBUTE_EXTERNALLY_VISIBLE
65# if __GNUC_PREREQ (4,1)
66# define ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((__externally_visible__))
67# else
68# define ATTRIBUTE_EXTERNALLY_VISIBLE
69# endif /* GNUC >= 4.1 */
70#endif /* ATTRIBUTE_EXTERNALLY_VISIBLE */
71
72/* We use __extension__ in some places to suppress -pedantic warnings
73 about GCC extensions. This feature didn't work properly before
74 gcc 2.8. */
75#if !__GNUC_PREREQ (2,8)
76# ifndef __extension__
77# define __extension__
78# endif
79#endif
80
Bernhard Reutner-Fischer86f5c992006-01-22 22:55:11 +000081#endif /* platform.h */