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> 2023-10-13 17:44:27-07:00
logb40943e253c079ec3de1b149dd2ef0ccc3da38a4
treee017fb02218974cb4d9cde29f9017fa5b721afe7
parentf9c9ae84c6c0773ab8dc710cae3ce9024ca1e91c

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.

3 files changed, 37 insertions(+), 0 deletions(-)

lib/libc/glibc/io/fcntl.h+7
......@@ -167,6 +167,10 @@ typedef __pid_t pid_t;
167167 effective IDs, not real IDs. */
168168#endif
169169
170
171/* fcntl was a simple symbol until glibc 2.27 inclusive. glibc 2.28 onwards
172 * re-defines it to fcntl64 (via #define) if _FILE_OFFSET_BITS == 64. */
173#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 28) || __GLIBC__ > 2
170174/* Do the file control operation described by CMD on FD.
171175 The remaining arguments are interpreted depending on CMD.
172176
......@@ -197,6 +201,9 @@ extern int __fcntl_time64 (int __fd, int __request, ...) __THROW;
197201# define fcntl __fcntl_time64
198202# endif
199203#endif
204#else /* glibc 2.27 or lower */
205extern int fcntl (int __fd, int __cmd, ...);
206#endif
200207
201208/* Open FILE and return a new file descriptor for it, or -1 on error.
202209 OFLAG determines the type of access used. If O_CREAT or O_TMPFILE is set
lib/libc/include/generic-glibc/fcntl.h+8
......@@ -167,6 +167,11 @@ typedef __pid_t pid_t;
167167 effective IDs, not real IDs. */
168168#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
170175/* Do the file control operation described by CMD on FD.
171176 The remaining arguments are interpreted depending on CMD.
172177
......@@ -197,6 +202,9 @@ extern int __fcntl_time64 (int __fd, int __request, ...) __THROW;
197202# define fcntl __fcntl_time64
198203# endif
199204#endif
205#else /* glibc 2.27 or lower */
206extern int fcntl (int __fd, int __cmd, ...);
207#endif
200208
201209/* Open FILE and return a new file descriptor for it, or -1 on error.
202210 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
170170#define res_init __res_init
171171#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
173195#ifdef _LIBC
174196# define __RESOLV_DEPRECATED
175197# define __RESOLV_DEPRECATED_MSG(msg)