X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fcompiler.h;h=6ce8f1aecb41f89e94f48ca3a0b03b9db42f68cc;hb=a0ee1f3ba1dd37945983ea651c98b49b318d3e2f;hp=8c2c3abd2ea6a808761eed046dce287f277ffaf9;hpb=028d89f9437e8fb25fd3fd67bcdd158819ce8557;p=pspp diff --git a/src/libpspp/compiler.h b/src/libpspp/compiler.h index 8c2c3abd2e..6ce8f1aecb 100644 --- a/src/libpspp/compiler.h +++ b/src/libpspp/compiler.h @@ -1,21 +1,18 @@ -/* PSPP - computes sample statistics. - Copyright (C) 2006 Free Software Foundation, Inc. - Written by Ben Pfaff . +/* PSPP - a program for statistical analysis. + Copyright (C) 2006, 2009, 2010, 2016 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ + along with this program. If not, see . */ #ifndef COMPILER_H #define COMPILER_H 1 @@ -32,14 +29,27 @@ #define ATTRIBUTE(X) #endif +/* Marks a function argument as possibly not used. */ #define UNUSED ATTRIBUTE ((unused)) + +/* Marks a function that will never return. */ #define NO_RETURN ATTRIBUTE ((noreturn)) -#define PRINTF_FORMAT(FMT, FIRST) ATTRIBUTE ((format (printf, FMT, FIRST))) -#define SCANF_FORMAT(FMT, FIRST) ATTRIBUTE ((format (scanf, FMT, FIRST))) -/* This attribute was added late in the GCC 2.x cycle. */ +/* Mark a function as taking a printf- or scanf-like format + string as its FMT'th argument and that the FIRST'th argument + is the first one to be checked against the format string. */ +#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__>= 4) || __GNUC__ > 4) +#define PRINTF_FORMAT(FMT, FIRST) ATTRIBUTE ((format (gnu_printf, FMT, FIRST))) +#else +#define PRINTF_FORMAT(FMT, FIRST) ATTRIBUTE ((format (__printf__, FMT, FIRST))) +#endif +#define SCANF_FORMAT(FMT, FIRST) ATTRIBUTE ((format (__scanf__, FMT, FIRST))) + +/* Tells the compiler that a function may be treated as if any + non-`NULL' pointer it returns cannot alias any other pointer + valid when the function returns. */ #if __GNUC__ > 2 -#define MALLOC_LIKE ATTRIBUTE ((malloc)) +#define MALLOC_LIKE ATTRIBUTE ((__malloc__)) #else #define MALLOC_LIKE #endif @@ -51,4 +61,45 @@ #define WARN_UNUSED_RESULT #endif +/* This attribute indicates that the function does not examine + any values except its arguments, and has no effects except the + return value. A function that has pointer arguments and + examines the data pointed to must _not_ be declared + `const'. */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5) +#define CONST_FUNCTION ATTRIBUTE ((const)) +#else +#define CONST_FUNCTION +#endif + +/* This attribute indicates that the function has no effects + except the return value and its return value depends only on + the parameters and/or global variables. */ +#if __GNUC__ > 2 +#define PURE_FUNCTION ATTRIBUTE ((pure)) +#else +#define PURE_FUNCTION +#endif + +/* This attribute indicates that the argument with the given + IDX must be a null pointer. IDX counts backward in the + argument list, so that 0 is the last argument, 1 is the + second-from-last argument, and so on. */ +#if __GNUC__ > 3 +#define SENTINEL(IDX) ATTRIBUTE ((sentinel(IDX))) +#else +#define SENTINEL(IDX) +#endif + + +/* This attribute indicates that the function should be compiled + with the specified LEVEL, regardless of what has been specified + on the command line */ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR >= 4) +#define OPTIMIZE(LEVEL) ATTRIBUTE ((optimize(LEVEL))) +#else +#define OPTIMIZE(LEVEL) +#endif + + #endif /* compiler.h */