File: attribute.h

package info (click to toggle)
nut 2.8.4%2Breally-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,720 kB
  • sloc: ansic: 132,030; sh: 17,256; cpp: 12,566; makefile: 5,646; python: 1,114; perl: 856; xml: 47
file content (71 lines) | stat: -rw-r--r-- 2,443 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* attribute.h - portability hacks for __attribute__ usage in other header files

   Copyright (C) 2001  Russell Kroll <rkroll@exploits.org>
	2005	Arnaud Quette <arnaud.quette@free.fr>
	2020	Jim Klimov <jimklimov@gmail.com>

   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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#ifndef NUT_ATTRIBUTE_H_SEEN
#define NUT_ATTRIBUTE_H_SEEN 1

/* To complicate matters, compilers with native support
 * for the keyword may expose or not expose it as a macro...
 * but for those that perform such courtesy, or are known
 * supporters, we can put up the flag. For others, someone
 * with those compilers should check and file PRs to NUT.
 */
#if (!defined HAVE___ATTRIBUTE__) || (HAVE___ATTRIBUTE__ == 0)
# if ( defined(__GNUC__) && ( __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) ) ) || ( defined(__STRICT_ANSI__) && __STRICT_ANSI__ )
#  ifndef __attribute__
#   define __attribute__(x)
#  endif
#  ifndef HAVE___ATTRIBUTE__
#   define HAVE___ATTRIBUTE__ 0
#  endif
# else
#  if defined(__clang__) || defined(__GNUC__) || defined(__SUNPRO_C)
#   ifndef HAVE___ATTRIBUTE__
#    define HAVE___ATTRIBUTE__ 1
#   endif
#  else
#   ifndef HAVE___ATTRIBUTE__
#    define HAVE___ATTRIBUTE__ 0
#   endif
#  endif
# endif
#endif

#if (!defined HAVE___ATTRIBUTE__) || (HAVE___ATTRIBUTE__ == 0)
# ifdef HAVE___ATTRIBUTE__UNUSED_ARG
#  undef HAVE___ATTRIBUTE__UNUSED_ARG
# endif
# ifdef HAVE___ATTRIBUTE__UNUSED_FUNC
#  undef HAVE___ATTRIBUTE__UNUSED_FUNC
# endif
# ifdef HAVE___ATTRIBUTE__NORETURN
#  undef HAVE___ATTRIBUTE__NORETURN
# endif
# ifdef HAVE___ATTRIBUTE__
#  undef HAVE___ATTRIBUTE__
# endif
#endif

/* Other source files now can simply check for `ifdef HAVE___ATTRIBUTE__*`
 * as usual, and not bother about 0/1 values of the macro as well.
 */

#endif /* NUT_ATTRIBUTE_H_SEEN */