patches/glibc/2.9/320-2.9-assume-pipe2.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun May 03 09:50:16 2009 +0000 (2009-05-03)
branchnewlib
changeset 1366 5e5d1e6f55d3
permissions -rw-r--r--
Update the newlib devel branch with stuff from /trunk@1498.

-------- diffstat follows --------
/devel/newlib/configure | 336 176 160 0 +++++++------
/devel/newlib/Makefile.in | 12 3 9 0 -
/devel/newlib/scripts/build/kernel/linux.sh | 2 1 1 0
/devel/newlib/scripts/build/internals.sh | 1 0 1 0 -
/devel/newlib/scripts/build/libc/eglibc.sh | 1 0 1 0 -
/devel/newlib/scripts/build/mpfr.sh | 2 1 1 0
/devel/newlib/scripts/functions | 111 5 106 0 ----
/devel/newlib/scripts/config.guess | 7 5 2 0 +
/devel/newlib/scripts/config.sub | 3 2 1 0 +
/devel/newlib/scripts/saveSample.sh.in | 4 2 2 0
/devel/newlib/docs/overview.txt | 8 6 2 0 +
/devel/newlib/samples/armeb-unknown-linux-uclibc/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/sh4-unknown-linux-gnu/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/x86_64-unknown-linux-gnu/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/arm-unknown-elf/crosstool.config | 12 3 9 0 -
/devel/newlib/samples/armeb-unknown-eabi/crosstool.config | 2 0 2 0 -
/devel/newlib/samples/arm-unknown-linux-gnueabi/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/ia64-unknown-linux-gnu/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/x86_64-unknown-linux-uclibc/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/armeb-unknown-linux-gnueabi/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/powerpc-e500v2-linux-gnuspe/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/i686-nptl-linux-gnu/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/arm-unknown-linux-gnu/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/powerpc-unknown-linux-gnu/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/mips-unknown-linux-uclibc/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/arm-unknown-linux-uclibcgnueabi/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/arm-iphone-linux-gnueabi/crosstool.config | 8 4 4 0
/devel/newlib/samples/armeb-unknown-linux-gnu/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/powerpc-unknown_nofpu-linux-gnu/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/i586-geode-linux-uclibc/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/arm-unknown-linux-uclibc/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/powerpc-unknown-linux-uclibc/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/mips-unknown-elf/crosstool.config | 2 0 2 0 -
/devel/newlib/samples/powerpc-405-linux-gnu/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/armeb-unknown-linux-uclibcgnueabi/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/arm-unknown-eabi/crosstool.config | 12 3 9 0 -
/devel/newlib/samples/mipsel-unknown-linux-gnu/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/powerpc64-unknown-linux-gnu/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/alphaev56-unknown-linux-gnu/crosstool.config | 14 5 9 0 -
/devel/newlib/samples/powerpc-860-linux-gnu/crosstool.config | 14 5 9 0 -
/devel/newlib/config/kernel/linux.in | 108 2 106 0 ----
/devel/newlib/config/global/ct-behave.in | 22 13 9 0 +
/devel/newlib/config/global/download.in | 210 15 195 0 +-------
/devel/newlib/config/libc/glibc.in | 7 7 0 0 +
/devel/newlib/config/libc/glibc-eglibc.in-common | 15 14 1 0 +
45 files changed, 382 insertions(+), 839 deletions(-)
yann@1365
     1
Original patch from: gentoo/src/patchsets/glibc/2.9/1095_all_glibc-2.9-assume-pipe2.patch
yann@1365
     2
yann@1365
     3
-= BEGIN original header =-
yann@1365
     4
http://bugs.gentoo.org/250342
yann@1365
     5
http://sources.redhat.com/bugzilla/show_bug.cgi?id=9685
yann@1365
     6
yann@1365
     7
we cant assume sock_cloexec and pipe2 are bound together as the former defines
yann@1365
     8
are found in glibc only while the latter are a combo of kernel headers and
yann@1365
     9
glibc.  so if we do a runtime detection of SOCK_CLOEXEC, but pipe2() is a stub
yann@1365
    10
inside of glibc, we hit a problem.  for example:
yann@1365
    11
yann@1365
    12
#include <grp.h>
yann@1365
    13
#include <stdio.h>
yann@1365
    14
main()
yann@1365
    15
{
yann@1365
    16
	getgrnam("portage");
yann@1365
    17
	if (!popen("ls", "r"))
yann@1365
    18
		perror("popen()");
yann@1365
    19
}
yann@1365
    20
yann@1365
    21
getgrnam() will detect that the kernel supports SOCK_CLOEXEC and then set both
yann@1365
    22
__have_sock_cloexec and __have_pipe2 to true.  but if glibc was built against
yann@1365
    23
older kernel headers where __NR_pipe2 does not exist, glibc will have a ENOSYS
yann@1365
    24
stub for it.  so popen() will always fail as glibc assumes pipe2() works.
yann@1365
    25
yann@1365
    26
-= END original header =-
yann@1365
    27
yann@1365
    28
diff -durN glibc-2_9.orig/include/unistd.h glibc-2_9/include/unistd.h
yann@1365
    29
--- glibc-2_9.orig/include/unistd.h	2008-07-27 20:23:17.000000000 +0200
yann@1365
    30
+++ glibc-2_9/include/unistd.h	2009-02-02 22:01:05.000000000 +0100
yann@1365
    31
@@ -167,9 +167,6 @@
yann@1365
    32
 extern int __pause_nocancel (void) attribute_hidden;
yann@1365
    33
 
yann@1365
    34
 extern int __have_sock_cloexec;
yann@1365
    35
-/* At lot of other functionality became available at the same time as
yann@1365
    36
-   SOCK_CLOEXEC.  Avoid defining separate variables for all of them
yann@1365
    37
-   unless it is really necessary.  */
yann@1365
    38
-#define __have_pipe2 __have_sock_cloexec
yann@1365
    39
+extern int __have_pipe2;
yann@1365
    40
 
yann@1365
    41
 #endif
yann@1365
    42
diff -durN glibc-2_9.orig/socket/have_sock_cloexec.c glibc-2_9/socket/have_sock_cloexec.c
yann@1365
    43
--- glibc-2_9.orig/socket/have_sock_cloexec.c	2008-07-25 18:46:23.000000000 +0200
yann@1365
    44
+++ glibc-2_9/socket/have_sock_cloexec.c	2009-02-02 22:01:05.000000000 +0100
yann@1365
    45
@@ -16,9 +16,14 @@
yann@1365
    46
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
yann@1365
    47
    02111-1307 USA.  */
yann@1365
    48
 
yann@1365
    49
+#include <fcntl.h>
yann@1365
    50
 #include <sys/socket.h>
yann@1365
    51
 #include <kernel-features.h>
yann@1365
    52
 
yann@1365
    53
 #if defined SOCK_CLOEXEC && !defined __ASSUME_SOCK_CLOEXEC
yann@1365
    54
 int __have_sock_cloexec;
yann@1365
    55
 #endif
yann@1365
    56
+
yann@1365
    57
+#if defined O_CLOEXEC && !defined __ASSUME_PIPE2
yann@1365
    58
+int __have_pipe2;
yann@1365
    59
+#endif