1 restore #undef'ed macro values after we're done
3 some programs that define these miss them if removed
5 push_macro and pop_macro pragmas allegedly well supported
8 --- a/include/fortify/poll.h
9 +++ b/include/fortify/poll.h
10 @@ -29,6 +29,7 @@ __extension__
14 +#pragma push_macro("poll")
17 _FORTIFY_FN(poll) int poll(struct pollfd * _FORTIFY_POS0 __f, nfds_t __n, int __s)
18 @@ -40,6 +41,8 @@ _FORTIFY_FN(poll) int poll(struct pollfd * _FORTIFY_POS0 __f, nfds_t __n, int __
19 return __orig_poll(__f, __n, __s);
22 +#pragma pop_macro("poll")
27 --- a/include/fortify/stdio.h
28 +++ b/include/fortify/stdio.h
29 @@ -29,12 +29,19 @@ __extension__
33 +#pragma push_macro("fgets")
35 +#pragma push_macro("fread")
37 +#pragma push_macro("fwrite")
39 +#pragma push_macro("vsprintf")
41 +#pragma push_macro("vsnprintf")
43 +#pragma push_macro("snprintf")
45 +#pragma push_macro("sprintf")
48 _FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f)
49 @@ -140,6 +147,14 @@ _FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...)
50 #endif /* __has_builtin(__builtin_va_arg_pack) */
51 #endif /* defined(__has_builtin) */
53 +#pragma pop_macro("fgets")
54 +#pragma pop_macro("fread")
55 +#pragma pop_macro("fwrite")
56 +#pragma pop_macro("vsprintf")
57 +#pragma pop_macro("vsnprintf")
58 +#pragma pop_macro("snprintf")
59 +#pragma pop_macro("sprintf")
64 --- a/include/fortify/stdlib.h
65 +++ b/include/fortify/stdlib.h
66 @@ -38,7 +38,10 @@ extern "C" {
69 #if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) && !defined(__clang__)
71 +#pragma push_macro("realpath")
74 _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r)
77 @@ -60,6 +63,9 @@ _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r)
78 return __orig_realpath(__p, __r);
82 +#pragma pop_macro("realpath")
87 --- a/include/fortify/string.h
88 +++ b/include/fortify/string.h
89 @@ -29,12 +29,19 @@ __extension__
93 +#pragma push_macro("memcpy")
95 +#pragma push_macro("memmove")
97 +#pragma push_macro("memset")
99 +#pragma push_macro("strcat")
101 +#pragma push_macro("strcpy")
103 +#pragma push_macro("strncat")
105 +#pragma push_macro("strncpy")
108 _FORTIFY_FN(memcpy) void *memcpy(void * _FORTIFY_POS0 __od,
109 @@ -183,6 +190,14 @@ _FORTIFY_FN(strlcpy) size_t strlcpy(char * _FORTIFY_POS0 __d,
113 +#pragma pop_macro("memcpy")
114 +#pragma pop_macro("memmove")
115 +#pragma pop_macro("memset")
116 +#pragma pop_macro("strcat")
117 +#pragma pop_macro("strcpy")
118 +#pragma pop_macro("strncat")
119 +#pragma pop_macro("strncpy")
124 --- a/include/fortify/strings.h
125 +++ b/include/fortify/strings.h
126 @@ -29,8 +29,12 @@ extern "C" {
127 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
128 || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
129 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
131 +#pragma push_macro("bcopy")
133 +#pragma push_macro("bzero")
136 _FORTIFY_FN(bcopy) void bcopy(const void * _FORTIFY_POS0 __s,
137 void * _FORTIFY_POS0 __d, size_t __n)
139 @@ -52,6 +56,9 @@ _FORTIFY_FN(bzero) void bzero(void * _FORTIFY_POS0 __s, size_t __n)
143 +#pragma pop_macro("bcopy")
144 +#pragma pop_macro("bzero")
149 --- a/include/fortify/sys/socket.h
150 +++ b/include/fortify/sys/socket.h
151 @@ -29,9 +29,13 @@ __extension__
155 +#pragma push_macro("recv")
157 +#pragma push_macro("recvfrom")
159 +#pragma push_macro("send")
161 +#pragma push_macro("sendto")
164 _FORTIFY_FN(recv) ssize_t recv(int __f, void * _FORTIFY_POS0 __s, size_t __n,
165 @@ -76,6 +80,11 @@ _FORTIFY_FN(sendto) ssize_t sendto(int __f, const void * _FORTIFY_POS0 __s,
166 return __orig_sendto(__f, __s, __n, __fl, __a, __l);
169 +#pragma push_macro("recv")
170 +#pragma push_macro("recvfrom")
171 +#pragma push_macro("send")
172 +#pragma push_macro("sendto")
177 --- a/include/fortify/unistd.h
178 +++ b/include/fortify/unistd.h
179 @@ -29,16 +29,27 @@ __extension__
183 +#pragma push_macro("confstr")
185 +#pragma push_macro("getcwd")
187 +#pragma push_macro("getgroups")
189 +#pragma push_macro("gethostname")
191 +#pragma push_macro("getlogin_r")
193 +#pragma push_macro("pread")
195 +#pragma push_macro("read")
197 +#pragma push_macro("readlink")
199 +#pragma push_macro("readlinkat")
201 +#pragma push_macro("ttyname_r")
203 +#pragma push_macro("write")
206 _FORTIFY_FN(confstr) size_t confstr(int __n, char * _FORTIFY_POS0 __s, size_t __l)
207 @@ -158,6 +169,18 @@ _FORTIFY_FN(write) ssize_t write(int __f, const void * _FORTIFY_POS0 __s,
208 return __orig_write(__f, __s, __n);
211 +#pragma pop_macro("confstr")
212 +#pragma pop_macro("getcwd")
213 +#pragma pop_macro("getgroups")
214 +#pragma pop_macro("gethostname")
215 +#pragma pop_macro("getlogin_r")
216 +#pragma pop_macro("pread")
217 +#pragma pop_macro("read")
218 +#pragma pop_macro("readlink")
219 +#pragma pop_macro("readlinkat")
220 +#pragma pop_macro("ttyname_r")
221 +#pragma pop_macro("write")
226 --- a/include/fortify/wchar.h
227 +++ b/include/fortify/wchar.h
228 @@ -43,19 +43,33 @@ __extension__
232 +#pragma push_macro("fgetws")
234 +#pragma push_macro("mbsrtowcs")
236 +#pragma push_macro("mbstowcs")
238 +#pragma push_macro("wcrtomb")
240 +#pragma push_macro("wcscat")
242 +#pragma push_macro("wcscpy")
244 +#pragma push_macro("wcsncat")
246 +#pragma push_macro("wcsncpy")
248 +#pragma push_macro("wcsrtombs")
250 +#pragma push_macro("wcstombs")
252 +#pragma push_macro("wctomb")
254 +#pragma push_macro("wmemcpy")
256 +#pragma push_macro("wmemmove")
258 +#pragma push_macro("wmemset")
261 _FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t * _FORTIFY_POS0 __s,
262 @@ -269,6 +283,21 @@ _FORTIFY_FN(wmemset) wchar_t *wmemset(wchar_t * _FORTIFY_POS0 __s,
263 return __orig_wmemset(__s, __c, __n);
266 +#pragma pop_macro("fgetws")
267 +#pragma pop_macro("mbsrtowcs")
268 +#pragma pop_macro("mbstowcs")
269 +#pragma pop_macro("wcrtomb")
270 +#pragma pop_macro("wcscat")
271 +#pragma pop_macro("wcscpy")
272 +#pragma pop_macro("wcsncat")
273 +#pragma pop_macro("wcsncpy")
274 +#pragma pop_macro("wcsrtombs")
275 +#pragma pop_macro("wcstombs")
276 +#pragma pop_macro("wctomb")
277 +#pragma pop_macro("wmemcpy")
278 +#pragma pop_macro("wmemmove")
279 +#pragma pop_macro("wmemset")