Skip to content

Commit

Permalink
glibc patch: add backwards compatibility for some symbols
Browse files Browse the repository at this point in the history
- `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.
  • Loading branch information
motiejus authored and andrewrk committed Jun 6, 2024
1 parent ad34de3 commit 9e76385
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/libc/glibc/io/fcntl.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ typedef __pid_t pid_t;
effective IDs, not real IDs. */
#endif


/* fcntl was a simple symbol until glibc 2.27 inclusive. glibc 2.28 onwards
* re-defines it to fcntl64 (via #define) if _FILE_OFFSET_BITS == 64. */
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 28) || __GLIBC__ > 2
/* Do the file control operation described by CMD on FD.
The remaining arguments are interpreted depending on CMD.
Expand Down Expand Up @@ -197,6 +201,9 @@ extern int __fcntl_time64 (int __fd, int __request, ...) __THROW;
# define fcntl __fcntl_time64
# endif
#endif
#else /* glibc 2.27 or lower */
extern int fcntl (int __fd, int __cmd, ...);
#endif

/* Open FILE and return a new file descriptor for it, or -1 on error.
OFLAG determines the type of access used. If O_CREAT or O_TMPFILE is set
Expand Down

0 comments on commit 9e76385

Please sign in to comment.