1 /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
2 
3    This program is free software; you can redistribute it and/or modify
4    it under the terms of the GNU General Public License, version 2.0,
5    as published by the Free Software Foundation.
6 
7    This program is also distributed with certain software (including
8    but not limited to OpenSSL) that is licensed under separate terms,
9    as designated in a particular file or component or in included license
10    documentation.  The authors of MySQL hereby grant you an additional
11    permission to link the program and your derivative works with the
12    separately licensed software that they have included with MySQL.
13 
14    Without limiting anything contained in the foregoing, this file,
15    which is part of C Driver for MySQL (Connector/C), is also subject to the
16    Universal FOSS Exception, version 1.0, a copy of which can be found at
17    http://oss.oracle.com/licenses/universal-foss-exception.
18 
19    This program is distributed in the hope that it will be useful,
20    but WITHOUT ANY WARRANTY; without even the implied warranty of
21    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22    GNU General Public License, version 2.0, for more details.
23 
24    You should have received a copy of the GNU General Public License
25    along with this program; if not, write to the Free Software
26    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
27 
28 /*
29   Helper macros used for setting different __attributes__
30   on functions in a portable fashion
31 */
32 
33 #ifndef _my_attribute_h
34 #define _my_attribute_h
35 
36 #if defined(__GNUC__)
37 # ifndef GCC_VERSION
38 #  define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
39 # endif
40 #endif
41 
42 /*
43   Disable MY_ATTRIBUTE() on g++ < 3.4, and non-gcc compilers.
44   Some forms of __attribute__ are actually supported in earlier versions of
45   g++, but we just disable them all because we only use them to generate
46   compilation warnings.
47 */
48 #ifndef MY_ATTRIBUTE
49 #if defined(__GNUC__) && GCC_VERSION > 3003
50 #  define MY_ATTRIBUTE(A) __attribute__(A)
51 #else
52 #  define MY_ATTRIBUTE(A)
53 #endif
54 #endif
55 
56 /*
57   __attribute__((format(...))) is only supported in g++ >= 3.4
58   But that's already covered by the MY_ATTRIBUTE tests above, so this is
59   just a convenience macro.
60 */
61 #ifndef ATTRIBUTE_FORMAT
62 #  define ATTRIBUTE_FORMAT(style, m, n) MY_ATTRIBUTE((format(style, m, n)))
63 #endif
64 
65 #ifndef ATTRIBUTE_FORMAT_FPTR
66 #  define ATTRIBUTE_FORMAT_FPTR(style, m, n) ATTRIBUTE_FORMAT(style, m, n)
67 #endif
68 
69 
70 #endif
71