mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-06 20:58:33 +01:00
sys/socket.h includes sys/uio.h to get the definition of the iovec structure. POSIX allows sys/socket.h to make all sys/uio.h symbols visible. However, all of sys/uio.h is XSI-shaded, so for non-XSI POSIX this results in conformtest failures (for sys/socket.h and other headers that include it): Namespace violation: "UIO_MAXIOV" Namespace violation: "readv" Namespace violation: "writev" Now, there is some ambiguity in POSIX about what namespace reservations apply in this case - see http://austingroupbugs.net/view.php?id=1127 - but glibc convention would still avoid declaring readv and writev, for example, for feature test macros that don't include them (if only headers from the relevant standard are included), even if such declarations are permitted, so there is a bug here according to glibc conventions. This patch moves the struct iovec definition to a new bits/types/struct_iovec.h header and includes that from sys/socket.h instead of including the whole of sys/uio.h. This fixes the namespace issue; however, three files in glibc that were relying on the implicit inclusion needed to be updated to include sys/uio.h explicitly. So there is a question of whether sys/socket.h should continue to include sys/uio.h under some conditions, such as __USE_XOPEN or __USE_MISC or __USE_XOPEN || __USE_MISC, for greater compatibility with code that (wrongly) expects this optional inclusion to be present there. (I think the three affected files in glibc should still have explicit sys/uio.h inclusions added in any case, however.) Tested for x86_64. [BZ #21426] * misc/bits/types/struct_iovec.h: New file. * misc/Makefile (headers): Add bits/types/struct_iovec.h. * include/bits/types/struct_iovec.h: New file. * bits/uio.h (struct iovec): Replace by inclusion of <bits/types/struct_iovec.h>. * sysdeps/unix/sysv/linux/bits/uio.h (struct iovec): Likewise. * socket/sys/socket.h: Include <bits/types/struct_iovec.h> instead of <sys/uio.h>. * nptl/tst-cancel4.c: Include <sys/uio.h> * posix/test-errno.c: Likewise. * support/resolv_test.c: Likewise. * conform/Makefile (test-xfail-POSIX2008/arpa/inet.h/conform): Remove. (test-xfail-POSIX2008/netdb.h/conform): Likewise. (test-xfail-POSIX2008/netinet/in.h/conform): Likewise. (test-xfail-POSIX2008/sys/socket.h/conform): Likewise.
72 lines
2.3 KiB
C
72 lines
2.3 KiB
C
/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#if !defined _SYS_UIO_H && !defined _FCNTL_H
|
|
# error "Never include <bits/uio.h> directly; use <sys/uio.h> instead."
|
|
#endif
|
|
|
|
#ifndef _BITS_UIO_H
|
|
#define _BITS_UIO_H 1
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
/* We should normally use the Linux kernel header file to define this
|
|
type and macros but this calls for trouble because of the header
|
|
includes other kernel headers. */
|
|
|
|
/* Size of object which can be written atomically.
|
|
|
|
This macro has different values in different kernel versions. The
|
|
latest versions of the kernel use 1024 and this is good choice. Since
|
|
the C library implementation of readv/writev is able to emulate the
|
|
functionality even if the currently running kernel does not support
|
|
this large value the readv/writev call will not fail because of this. */
|
|
#define UIO_MAXIOV 1024
|
|
|
|
|
|
#include <bits/types/struct_iovec.h>
|
|
|
|
#endif
|
|
|
|
|
|
#ifdef __USE_GNU
|
|
# if defined _SYS_UIO_H && !defined _BITS_UIO_H_FOR_SYS_UIO_H
|
|
# define _BITS_UIO_H_FOR_SYS_UIO_H 1
|
|
|
|
__BEGIN_DECLS
|
|
|
|
/* Read from another process' address space. */
|
|
extern ssize_t process_vm_readv (pid_t __pid, const struct iovec *__lvec,
|
|
unsigned long int __liovcnt,
|
|
const struct iovec *__rvec,
|
|
unsigned long int __riovcnt,
|
|
unsigned long int __flags)
|
|
__THROW;
|
|
|
|
/* Write to another process' address space. */
|
|
extern ssize_t process_vm_writev (pid_t __pid, const struct iovec *__lvec,
|
|
unsigned long int __liovcnt,
|
|
const struct iovec *__rvec,
|
|
unsigned long int __riovcnt,
|
|
unsigned long int __flags)
|
|
__THROW;
|
|
|
|
__END_DECLS
|
|
|
|
# endif
|
|
#endif
|