Remove "Written by Ben Pfaff <blp@gnu.org>" lines everywhere.
[pspp-builds.git] / src / libpspp / compiler.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 2006 Free Software Foundation, Inc.
3
4    This program is free software; you can redistribute it and/or
5    modify it under the terms of the GNU General Public License as
6    published by the Free Software Foundation; either version 2 of the
7    License, or (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful, but
10    WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17    02110-1301, USA. */
18
19 #ifndef COMPILER_H
20 #define COMPILER_H 1
21
22 /* GNU C allows the programmer to declare that certain functions take
23    printf-like arguments, never return, etc.  Conditionalize these
24    declarations on whether gcc is in use. */
25 #if __GNUC__ > 1
26 #define ATTRIBUTE(X) __attribute__ (X)
27
28 /* Only necessary because of a wart in gnulib's xalloc.h. */
29 #define __attribute__(X) __attribute__ (X)
30 #else
31 #define ATTRIBUTE(X)
32 #endif
33
34 /* Marks a function argument as possibly not used. */
35 #define UNUSED ATTRIBUTE ((unused))
36
37 /* Marks a function that will never return. */
38 #define NO_RETURN ATTRIBUTE ((noreturn))
39
40 /* Mark a function as taking a printf- or scanf-like format
41    string as its FMT'th argument and that the FIRST'th argument
42    is the first one to be checked against the format string. */
43 #define PRINTF_FORMAT(FMT, FIRST) ATTRIBUTE ((format (printf, FMT, FIRST)))
44 #define SCANF_FORMAT(FMT, FIRST) ATTRIBUTE ((format (scanf, FMT, FIRST)))
45
46 /* Tells the compiler that a function may be treated as if any
47    non-`NULL' pointer it returns cannot alias any other pointer
48    valid when the function returns. */
49 #if __GNUC__ > 2
50 #define MALLOC_LIKE ATTRIBUTE ((malloc))
51 #else
52 #define MALLOC_LIKE
53 #endif
54
55 /* This attribute was added in GCC 4.0. */
56 #if __GNUC__ >= 4
57 #define WARN_UNUSED_RESULT ATTRIBUTE ((warn_unused_result))
58 #else
59 #define WARN_UNUSED_RESULT
60 #endif
61
62 /* This attribute indicates that the function does not examine
63    any values except its arguments, and has no effects except the
64    return value.  A function that has pointer arguments and
65    examines the data pointed to must _not_ be declared
66    `const'.  */
67 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5)
68 #define CONST_FUNCTION ATTRIBUTE ((const))
69 #else
70 #define CONST_FUNCTION
71 #endif
72
73 /* This attribute indicates that the function has no effects
74    except the return value and its return value depends only on
75    the parameters and/or global variables. */
76 #if __GNUC__ > 2
77 #define PURE_FUNCTION ATTRIBUTE ((pure))
78 #else
79 #define PURE_FUNCTION
80 #endif
81
82 #endif /* compiler.h */