(EINTR): Define.
[gnulib.git] / lib / fatal.h
1 #include "error.h"
2
3 /* FIXME: this is all from ansidecl.  better to simply swipe
4    that file from egcs/include and include it from here.  */
5
6 /* Using MACRO(x,y) in cpp #if conditionals does not work with some
7    older preprocessors.  Thus we can't define something like this:
8
9 #define HAVE_GCC_VERSION(MAJOR, MINOR) \
10   (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
11
12 and then test "#if HAVE_GCC_VERSION(2,7)".
13
14 So instead we use the macro below and test it against specific values.  */
15
16 /* This macro simplifies testing whether we are using gcc, and if it
17    is of a particular minimum version. (Both major & minor numbers are
18    significant.)  This macro will evaluate to 0 if we are not using
19    gcc at all.  */
20 #ifndef GCC_VERSION
21 # define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
22 #endif /* GCC_VERSION */
23
24 /* Define macros for some gcc attributes.  This permits us to use the
25    macros freely, and know that they will come into play for the
26    version of gcc in which they are supported.  */
27
28 #if (GCC_VERSION < 2007)
29 # define __attribute__(x)
30 #endif
31
32 /* Attribute __malloc__ on functions was valid as of gcc 2.96. */
33 #ifndef ATTRIBUTE_MALLOC
34 # if (GCC_VERSION >= 2096)
35 #  define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
36 # else
37 #  define ATTRIBUTE_MALLOC
38 # endif /* GNUC >= 2.96 */
39 #endif /* ATTRIBUTE_MALLOC */
40
41 /* Attributes on labels were valid as of gcc 2.93. */
42 #ifndef ATTRIBUTE_UNUSED_LABEL
43 # if (GCC_VERSION >= 2093)
44 #  define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED
45 # else
46 #  define ATTRIBUTE_UNUSED_LABEL
47 # endif /* GNUC >= 2.93 */
48 #endif /* ATTRIBUTE_UNUSED_LABEL */
49
50 #ifndef ATTRIBUTE_UNUSED
51 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
52 #endif /* ATTRIBUTE_UNUSED */
53
54 #ifndef ATTRIBUTE_NORETURN
55 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
56 #endif /* ATTRIBUTE_NORETURN */
57
58 #ifndef ATTRIBUTE_PRINTF
59 # define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
60 # define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
61 # define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
62 # define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
63 # define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
64 # define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
65 #endif /* ATTRIBUTE_PRINTF */
66
67 extern void fatal (int errnum, const char *format, ...)
68      ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_2;