blob: aa61e15c816a0958769fa95acdbbafe693bc0329 [file] [log] [blame]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001From f32126ba790dd4e61d43a2140b24f02426297bb6 Mon Sep 17 00:00:00 2001
2From: "Dmitry V. Levin" <ldv@altlinux.org>
3Date: Thu, 31 Dec 2015 14:19:41 +0000
4Subject: [PATCH] Move gcc compat macros to gcc_compat.h
5
6* defs.h: Include "gcc_compat.h".
7(GNUC_PREREQ, ATTRIBUTE_NORETURN, ATTRIBUTE_FORMAT,
8ATTRIBUTE_ALIGNED, ATTRIBUTE_PACKED, ATTRIBUTE_MALLOC,
9ATTRIBUTE_NOINLINE, ATTRIBUTE_ALLOC_SIZE): Move ...
10* gcc_compat.h: ... here.
11* Makefile.am (strace_SOURCES): Add gcc_compat.h.
12---
13Signed-off-by: Khem Raj <raj.khem@gmail.com>
14Upstream-Status: Backport
15
16 Makefile.am | 1 +
17 defs.h | 43 +----------------------------------
18 gcc_compat.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19 3 files changed, 75 insertions(+), 42 deletions(-)
20 create mode 100644 gcc_compat.h
21
22diff --git a/Makefile.am b/Makefile.am
23index ab52778..d43608d 100644
24--- a/Makefile.am
25+++ b/Makefile.am
26@@ -97,6 +97,7 @@ strace_SOURCES = \
27 flock.c \
28 flock.h \
29 futex.c \
30+ gcc_compat.h \
31 get_robust_list.c \
32 getcpu.c \
33 getcwd.c \
34diff --git a/defs.h b/defs.h
35index 283ab1f..bae212c 100644
36--- a/defs.h
37+++ b/defs.h
38@@ -55,6 +55,7 @@
39 #include <sys/syscall.h>
40
41 #include "mpers_type.h"
42+#include "gcc_compat.h"
43
44 #ifndef HAVE_STRERROR
45 const char *strerror(int);
46@@ -68,48 +69,6 @@ const char *strerror(int);
47 extern char *stpcpy(char *dst, const char *src);
48 #endif
49
50-#if defined __GNUC__ && defined __GNUC_MINOR__
51-# define GNUC_PREREQ(maj, min) \
52- ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
53-#else
54-# define __attribute__(x) /* empty */
55-# define GNUC_PREREQ(maj, min) 0
56-#endif
57-
58-#if GNUC_PREREQ(2, 5)
59-# define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
60-#else
61-# define ATTRIBUTE_NORETURN /* empty */
62-#endif
63-
64-#if GNUC_PREREQ(2, 7)
65-# define ATTRIBUTE_FORMAT(args) __attribute__((__format__ args))
66-# define ATTRIBUTE_ALIGNED(arg) __attribute__((__aligned__(arg)))
67-# define ATTRIBUTE_PACKED __attribute__((__packed__))
68-#else
69-# define ATTRIBUTE_FORMAT(args) /* empty */
70-# define ATTRIBUTE_ALIGNED(arg) /* empty */
71-# define ATTRIBUTE_PACKED /* empty */
72-#endif
73-
74-#if GNUC_PREREQ(3, 0)
75-# define ATTRIBUTE_MALLOC __attribute__((__malloc__))
76-#else
77-# define ATTRIBUTE_MALLOC /* empty */
78-#endif
79-
80-#if GNUC_PREREQ(3, 1)
81-# define ATTRIBUTE_NOINLINE __attribute__((__noinline__))
82-#else
83-# define ATTRIBUTE_NOINLINE /* empty */
84-#endif
85-
86-#if GNUC_PREREQ(4, 3)
87-# define ATTRIBUTE_ALLOC_SIZE(args) __attribute__((__alloc_size__ args))
88-#else
89-# define ATTRIBUTE_ALLOC_SIZE(args) /* empty */
90-#endif
91-
92 #ifndef offsetof
93 # define offsetof(type, member) \
94 (((char *) &(((type *) NULL)->member)) - ((char *) (type *) NULL))
95diff --git a/gcc_compat.h b/gcc_compat.h
96new file mode 100644
97index 0000000..1f2c835
98--- /dev/null
99+++ b/gcc_compat.h
100@@ -0,0 +1,73 @@
101+/*
102+ * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
103+ * All rights reserved.
104+ *
105+ * Redistribution and use in source and binary forms, with or without
106+ * modification, are permitted provided that the following conditions
107+ * are met:
108+ * 1. Redistributions of source code must retain the above copyright
109+ * notice, this list of conditions and the following disclaimer.
110+ * 2. Redistributions in binary form must reproduce the above copyright
111+ * notice, this list of conditions and the following disclaimer in the
112+ * documentation and/or other materials provided with the distribution.
113+ * 3. The name of the author may not be used to endorse or promote products
114+ * derived from this software without specific prior written permission.
115+ *
116+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
117+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
118+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
119+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
120+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
121+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
122+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
123+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
124+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
125+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
126+ */
127+
128+#ifndef GCC_COMPAT_H_
129+#define GCC_COMPAT_H_
130+
131+#if defined __GNUC__ && defined __GNUC_MINOR__
132+# define GNUC_PREREQ(maj, min) \
133+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
134+#else
135+# define __attribute__(x) /* empty */
136+# define GNUC_PREREQ(maj, min) 0
137+#endif
138+
139+#if GNUC_PREREQ(2, 5)
140+# define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
141+#else
142+# define ATTRIBUTE_NORETURN /* empty */
143+#endif
144+
145+#if GNUC_PREREQ(2, 7)
146+# define ATTRIBUTE_FORMAT(args) __attribute__((__format__ args))
147+# define ATTRIBUTE_ALIGNED(arg) __attribute__((__aligned__(arg)))
148+# define ATTRIBUTE_PACKED __attribute__((__packed__))
149+#else
150+# define ATTRIBUTE_FORMAT(args) /* empty */
151+# define ATTRIBUTE_ALIGNED(arg) /* empty */
152+# define ATTRIBUTE_PACKED /* empty */
153+#endif
154+
155+#if GNUC_PREREQ(3, 0)
156+# define ATTRIBUTE_MALLOC __attribute__((__malloc__))
157+#else
158+# define ATTRIBUTE_MALLOC /* empty */
159+#endif
160+
161+#if GNUC_PREREQ(3, 1)
162+# define ATTRIBUTE_NOINLINE __attribute__((__noinline__))
163+#else
164+# define ATTRIBUTE_NOINLINE /* empty */
165+#endif
166+
167+#if GNUC_PREREQ(4, 3)
168+# define ATTRIBUTE_ALLOC_SIZE(args) __attribute__((__alloc_size__ args))
169+#else
170+# define ATTRIBUTE_ALLOC_SIZE(args) /* empty */
171+#endif
172+
173+#endif
174--
1751.9.1
176