Skip to content

Commit 8ad0732

Browse files
authored
Merge pull request #22771 from chouquette/chouquette/glibc_guard
glibc: guard more function declarations
2 parents 2d4954a + edee702 commit 8ad0732

File tree

5 files changed

+34
-5
lines changed

5 files changed

+34
-5
lines changed

lib/libc/include/generic-glibc/bits/spawn_ext.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ extern int posix_spawnattr_setcgroup_np (posix_spawnattr_t *__attr,
3535
int __cgroup)
3636
__THROW __nonnull ((1));
3737

38+
// zig patch: check target glibc version
39+
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 39) || __GLIBC__ > 2
3840
/* Spawn a new process executing PATH with the attributes describes in *ATTRP.
3941
Before running the process perform the actions described in FACTS. Return
4042
a PID file descriptor in PIDFD if process creation was successful and the
@@ -61,7 +63,8 @@ extern int pidfd_spawnp (int *__restrict __pidfd,
6163
char *const __argv[__restrict_arr],
6264
char *const __envp[__restrict_arr])
6365
__nonnull ((1, 2, 5));
66+
#endif /* (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 39) || __GLIBC__ > 2 */
6467

6568
#endif /* __USE_MISC */
6669

67-
__END_DECLS
70+
__END_DECLS

lib/libc/include/generic-glibc/bits/statx-generic.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#include <bits/types/struct_statx_timestamp.h>
2626
#include <bits/types/struct_statx.h>
2727

28+
// zig patch: check target glibc version
29+
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 28) || __GLIBC__ > 2
30+
2831
#ifndef STATX_TYPE
2932
# define STATX_TYPE 0x0001U
3033
# define STATX_MODE 0x0002U
@@ -63,4 +66,6 @@ int statx (int __dirfd, const char *__restrict __path, int __flags,
6366
unsigned int __mask, struct statx *__restrict __buf)
6467
__THROW __nonnull ((2, 5));
6568

66-
__END_DECLS
69+
__END_DECLS
70+
71+
#endif /* (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 28) || __GLIBC__ > 2 */

lib/libc/include/generic-glibc/sys/mount.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ struct mount_attr
235235
#define FSPICK_NO_AUTOMOUNT 0x00000004
236236
#define FSPICK_EMPTY_PATH 0x00000008
237237

238+
// zig patch: check target glibc version
239+
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 36) || __GLIBC__ > 2
238240

239241
#ifndef FSOPEN_CLOEXEC
240242
/* The type of fsconfig call made. */
@@ -268,6 +270,7 @@ enum fsconfig_command
268270
#define OPEN_TREE_CLONE 1 /* Clone the target tree and attach the clone */
269271
#define OPEN_TREE_CLOEXEC O_CLOEXEC /* Close the file on execve() */
270272

273+
#endif
271274

272275
__BEGIN_DECLS
273276

@@ -282,6 +285,9 @@ extern int umount (const char *__special_file) __THROW;
282285
/* Unmount a filesystem. Force unmounting if FLAGS is set to MNT_FORCE. */
283286
extern int umount2 (const char *__special_file, int __flags) __THROW;
284287

288+
// zig patch: check target glibc version
289+
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 36) || __GLIBC__ > 2
290+
285291
/* Open the filesystem referenced by FS_NAME so it can be configured for
286292
mouting. */
287293
extern int fsopen (const char *__fs_name, unsigned int __flags) __THROW;
@@ -320,6 +326,8 @@ extern int mount_setattr (int __dfd, const char *__path, unsigned int __flags,
320326
struct mount_attr *__uattr, size_t __usize)
321327
__THROW;
322328

329+
#endif /* (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 36) || __GLIBC__ > 2 */
330+
323331
__END_DECLS
324332

325-
#endif /* _SYS_MOUNT_H */
333+
#endif /* _SYS_MOUNT_H */

lib/libc/include/generic-glibc/sys/pidfd.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#include <fcntl.h>
2222
#include <bits/types/siginfo_t.h>
2323

24+
// zig patch: check target glibc version
25+
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 36) || __GLIBC__ > 2
26+
2427
#define PIDFD_NONBLOCK O_NONBLOCK
2528
#define PIDFD_THREAD O_EXCL
2629

@@ -45,8 +48,15 @@ extern int pidfd_getfd (int __pidfd, int __targetfd,
4548
extern int pidfd_send_signal (int __pidfd, int __sig, siginfo_t *__info,
4649
unsigned int __flags) __THROW;
4750

51+
#endif /* (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 36) || __GLIBC__ > 2 */
52+
53+
// zig patch: check target glibc version
54+
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 39) || __GLIBC__ > 2
55+
4856
/* Query the process ID (PID) from process descriptor FD. Return the PID
4957
or -1 in case of an error. */
5058
extern pid_t pidfd_getpid (int __fd) __THROW;
5159

52-
#endif /* _PIDFD_H */
60+
#endif /* (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 36) || __GLIBC__ > 2 */
61+
62+
#endif /* _PIDFD_H */

lib/libc/include/generic-glibc/unistd.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,13 +1203,16 @@ int getentropy (void *__buffer, size_t __length) __wur
12031203
#endif
12041204

12051205
#ifdef __USE_GNU
1206+
// zig patch: check target glibc version
1207+
# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 34) || __GLIBC__ > 2
12061208
/* Close all file descriptors in the range FD up to MAX_FD. The flag FLAGS
12071209
are define by the CLOSE_RANGE prefix. This function behaves like close
12081210
on the range and gaps where the file descriptor is invalid or errors
12091211
encountered while closing file descriptors are ignored. Returns 0 on
12101212
successor or -1 for failure (and sets errno accordingly). */
12111213
extern int close_range (unsigned int __fd, unsigned int __max_fd,
12121214
int __flags) __THROW;
1215+
# endif
12131216
#endif
12141217

12151218
/* Define some macros helping to catch buffer overflows. */
@@ -1222,4 +1225,4 @@ extern int close_range (unsigned int __fd, unsigned int __max_fd,
12221225

12231226
__END_DECLS
12241227

1225-
#endif /* unistd.h */
1228+
#endif /* unistd.h */

0 commit comments

Comments
 (0)