authorgravatar for motiejus@jakstys.ltMotiejus Jakštys <motiejus@jakstys.lt> 2023-03-28 20:30:06+03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-06-05 22:43:53-07:00
log5af14711a86cccf5b205ed148cd79efcb03689b3
treee3b6d61f1a9c31105deb61fa99d81d04e0c2d87a
parenta4a88e441f989942400dac8ac9b7f7e1a8f83b22

glibc patch: add backwards compatibility for some symbols

- `fcntl` was renamed to `fcntl64` in glibc 2.28 (see #9485) - `res_{,n}{search,query,querydomain}` became "their own" symbols since glibc 2.34: they were prefixed with `__` before. This PR makes it possible to use `fcntl` with glibc 2.27 or older and the `res_*` functions with glibc 2.33 or older. These patches will become redundant with universal-headers and can be dropped. But we have to do with what we have now.

2 files changed, 30 insertions(+), 0 deletions(-)

lib/libc/include/generic-glibc/fcntl.h+8
...@@ -167,6 +167,11 @@ typedef __pid_t pid_t;...@@ -167,6 +167,11 @@ typedef __pid_t pid_t;
167 effective IDs, not real IDs. */167 effective IDs, not real IDs. */
168#endif168#endif
169169
170
171/* fcntl was a simple symbol until glibc 2.27 inclusive.
172 * glibc 2.28 onwards converted it to a macro when compiled with
173 * USE_LARGEFILE64. */
174#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 28) || __GLIBC__ > 2
170/* Do the file control operation described by CMD on FD.175/* Do the file control operation described by CMD on FD.
171 The remaining arguments are interpreted depending on CMD.176 The remaining arguments are interpreted depending on CMD.
172177
...@@ -197,6 +202,9 @@ extern int __fcntl_time64 (int __fd, int __request, ...) __THROW;...@@ -197,6 +202,9 @@ extern int __fcntl_time64 (int __fd, int __request, ...) __THROW;
197# define fcntl __fcntl_time64202# define fcntl __fcntl_time64
198# endif203# endif
199#endif204#endif
205#else /* glibc 2.27 or lower */
206extern int fcntl (int __fd, int __cmd, ...);
207#endif
200208
201/* Open FILE and return a new file descriptor for it, or -1 on error.209/* Open FILE and return a new file descriptor for it, or -1 on error.
202 OFLAG determines the type of access used. If O_CREAT or O_TMPFILE is set210 OFLAG determines the type of access used. If O_CREAT or O_TMPFILE is set
lib/libc/include/generic-glibc/resolv.h+22
...@@ -170,6 +170,28 @@ __END_DECLS...@@ -170,6 +170,28 @@ __END_DECLS
170#define res_init __res_init170#define res_init __res_init
171#define res_isourserver __res_isourserver171#define res_isourserver __res_isourserver
172172
173/* In glibc 2.33 and earlier res_search, res_nsearch, res_query, res_nquery,
174 * res_querydomain, res_nquerydomain were #define'd to __res_search,
175 * __res_nsearch, etc. glibc 2.34 onwards removes the macros and exposes the
176 * symbols directly. New glibc exposes compat symbols with underscores for
177 * backwards compatibility. Applications linked to glibc 2.34+ are expected
178 * to use the non-underscored symbols.
179 *
180 * It will be enough to bring the macros back when compiling against the older
181 * glibc versions.
182 *
183 * See glibc commit ea9878ec271c791880fcbbe519d70c42f8113750.
184 */
185#if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 34)
186#define res_search __res_search
187#define res_nsearch __res_nsearch
188#define res_query __res_query
189#define res_nquery __res_nquery
190#define res_querydomain __res_querydomain
191#define res_nquerydomain __res_nquerydomain
192#endif
193/* end glibc compat hacks */
194
173#ifdef _LIBC195#ifdef _LIBC
174# define __RESOLV_DEPRECATED196# define __RESOLV_DEPRECATED
175# define __RESOLV_DEPRECATED_MSG(msg)197# define __RESOLV_DEPRECATED_MSG(msg)