1 /* PSPP - a program for statistical analysis. 2 Copyright (C) 2006, 2009, 2010, 2016 Free Software Foundation, Inc. 3 4 This program is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 3 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU 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, see <http://www.gnu.org/licenses/>. */ 16 17 #ifndef COMPILER_H 18 #define COMPILER_H 1 19 20 /* GNU C allows the programmer to declare that certain functions take 21 printf-like arguments, never return, etc. Conditionalize these 22 declarations on whether gcc is in use. */ 23 #if __GNUC__ > 1 24 #define ATTRIBUTE(X) __attribute__ (X) 25 26 /* Only necessary because of a wart in gnulib's xalloc.h. */ 27 #define __attribute__(X) __attribute__ (X) 28 #else 29 #define ATTRIBUTE(X) 30 #endif 31 32 /* Marks a function argument as possibly not used. */ 33 #define UNUSED ATTRIBUTE ((unused)) 34 35 /* Marks a function that will never return. */ 36 #define NO_RETURN ATTRIBUTE ((noreturn)) 37 38 /* Mark a function as taking a printf- or scanf-like format 39 string as its FMT'th argument and that the FIRST'th argument 40 is the first one to be checked against the format string. */ 41 #define PRINTF_FORMAT(FMT, FIRST) ATTRIBUTE ((format (__printf__, FMT, FIRST))) 42 #define SCANF_FORMAT(FMT, FIRST) ATTRIBUTE ((format (__scanf__, FMT, FIRST))) 43 44 /* Tells the compiler that a function may be treated as if any 45 non-`NULL' pointer it returns cannot alias any other pointer 46 valid when the function returns. */ 47 #if __GNUC__ > 2 48 #define MALLOC_LIKE ATTRIBUTE ((__malloc__)) 49 #else 50 #define MALLOC_LIKE 51 #endif 52 53 /* This attribute was added in GCC 4.0. */ 54 #if __GNUC__ >= 4 55 #define WARN_UNUSED_RESULT ATTRIBUTE ((warn_unused_result)) 56 #else 57 #define WARN_UNUSED_RESULT 58 #endif 59 60 /* This attribute indicates that the function does not examine 61 any values except its arguments, and has no effects except the 62 return value. A function that has pointer arguments and 63 examines the data pointed to must _not_ be declared 64 `const'. */ 65 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5) 66 #define CONST_FUNCTION ATTRIBUTE ((const)) 67 #else 68 #define CONST_FUNCTION 69 #endif 70 71 /* This attribute indicates that the function has no effects 72 except the return value and its return value depends only on 73 the parameters and/or global variables. */ 74 #if __GNUC__ > 2 75 #define PURE_FUNCTION ATTRIBUTE ((pure)) 76 #else 77 #define PURE_FUNCTION 78 #endif 79 80 /* This attribute indicates that the argument with the given 81 IDX must be a null pointer. IDX counts backward in the 82 argument list, so that 0 is the last argument, 1 is the 83 second-from-last argument, and so on. */ 84 #if __GNUC__ > 3 85 #define SENTINEL(IDX) ATTRIBUTE ((sentinel(IDX))) 86 #else 87 #define SENTINEL(IDX) 88 #endif 89 90 91 /* This attribute indicates that the function should be compiled 92 with the specified LEVEL, regardless of what has been specified 93 on the command line */ 94 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR >= 4) 95 #define OPTIMIZE(LEVEL) ATTRIBUTE ((optimize(LEVEL))) 96 #else 97 #define OPTIMIZE(LEVEL) 98 #endif 99 100 101 #endif /* compiler.h */ 102