From d0145e03799e484f3a53d79de3b3f34162ee9d3c Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 24 Apr 2006 08:55:46 +0000 Subject: Updated to fedora-glibc-20060424T0820 --- posix/Makefile | 2 +- posix/bits/unistd.h | 16 +++---- posix/regex.h | 11 +---- posix/tst-rfc3484-2.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++ posix/tst-rfc3484.c | 4 +- posix/unistd.h | 9 ++-- 6 files changed, 146 insertions(+), 24 deletions(-) create mode 100644 posix/tst-rfc3484-2.c (limited to 'posix') diff --git a/posix/Makefile b/posix/Makefile index a0c7b94b02..57f2f94d59 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -88,7 +88,7 @@ tests := tstgetopt testfnm runtests runptests \ tst-execvp1 tst-execvp2 tst-execlp1 tst-execlp2 \ tst-execv1 tst-execv2 tst-execl1 tst-execl2 \ tst-execve1 tst-execve2 tst-execle1 tst-execle2 \ - tst-execvp3 tst-execvp4 tst-rfc3484 + tst-execvp3 tst-execvp4 tst-rfc3484 tst-rfc3484-2 xtests := bug-ga2 ifeq (yes,$(build-shared)) test-srcs := globtest diff --git a/posix/bits/unistd.h b/posix/bits/unistd.h index b72b7c758a..d461108e53 100644 --- a/posix/bits/unistd.h +++ b/posix/bits/unistd.h @@ -1,5 +1,5 @@ /* Checking macros for unistd functions. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2006 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 @@ -80,16 +80,16 @@ pread64 (int __fd, void *__buf, size_t __nbytes, __off64_t __offset) #endif #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K -extern int __readlink_chk (__const char *__restrict __path, - char *__restrict __buf, size_t __len, - size_t __buflen) +extern ssize_t __readlink_chk (__const char *__restrict __path, + char *__restrict __buf, size_t __len, + size_t __buflen) __THROW __nonnull ((1, 2)) __wur; -extern int __REDIRECT_NTH (__readlink_alias, - (__const char *__restrict __path, - char *__restrict __buf, size_t __len), readlink) +extern ssize_t __REDIRECT_NTH (__readlink_alias, + (__const char *__restrict __path, + char *__restrict __buf, size_t __len), readlink) __nonnull ((1, 2)) __wur; -extern __always_inline __nonnull ((1, 2)) __wur int +extern __always_inline __nonnull ((1, 2)) __wur ssize_t __NTH (readlink (__const char *__restrict __path, char *__restrict __buf, size_t __len)) { diff --git a/posix/regex.h b/posix/regex.h index f6c145d209..d787b9bff9 100644 --- a/posix/regex.h +++ b/posix/regex.h @@ -1,6 +1,6 @@ /* Definitions for data structures and routines for the regular expression library. - Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005 + Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -29,15 +29,6 @@ extern "C" { #endif -/* POSIX says that must be included (by the caller) before - . */ - -#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS -/* VMS doesn't have `size_t' in , even though POSIX says it - should be there. */ -# include -#endif - /* The following two types have to be signed and unsigned integer type wide enough to hold a value of a pointer. For most ANSI compilers ptrdiff_t and size_t should be likely OK. Still size of these two diff --git a/posix/tst-rfc3484-2.c b/posix/tst-rfc3484-2.c new file mode 100644 index 0000000000..b3987c8cd5 --- /dev/null +++ b/posix/tst-rfc3484-2.c @@ -0,0 +1,128 @@ +#include +#include + +/* Internal definitions used in the libc code. */ +#define __getservbyname_r getservbyname_r +#define __socket socket +#define __getsockname getsockname +#define __inet_aton inet_aton +#define __gethostbyaddr_r gethostbyaddr_r +#define __gethostbyname2_r gethostbyname2_r + +void +attribute_hidden +__check_pf (bool *p1, bool *p2, struct in6addrinfo **in6ai, size_t *in6ailen) +{ + *p1 = *p2 = true; + *in6ai = NULL; + *in6ailen = 0; +} +int +__idna_to_ascii_lz (const char *input, char **output, int flags) +{ + return 0; +} +int +__idna_to_unicode_lzlz (const char *input, char **output, int flags) +{ + return 0; +} + +#include "../sysdeps/posix/getaddrinfo.c" + +service_user *__nss_hosts_database attribute_hidden; + + +/* This is the beginning of the real test code. The above defines + (among other things) the function rfc3484_sort. */ + + +#if __BYTE_ORDER == __BIG_ENDIAN +# define h(n) n +#else +# define h(n) __bswap_constant_32 (n) +#endif + + +static int +do_test (void) +{ + struct sockaddr_in so1; + so1.sin_family = AF_INET; + so1.sin_addr.s_addr = h (0xc0a85f19); + + struct sockaddr_in sa1; + sa1.sin_family = AF_INET; + sa1.sin_addr.s_addr = h (0xe0a85f19); + + struct addrinfo ai1; + ai1.ai_family = AF_INET; + ai1.ai_addr = (struct sockaddr *) &sa1; + + struct sockaddr_in6 so2; + so2.sin6_family = AF_INET6; + so2.sin6_addr.s6_addr32[0] = h (0xfec01234); + so2.sin6_addr.s6_addr32[1] = 1; + so2.sin6_addr.s6_addr32[2] = 1; + so2.sin6_addr.s6_addr32[3] = 1; + + struct sockaddr_in6 sa2; + sa2.sin6_family = AF_INET6; + sa2.sin6_addr.s6_addr32[0] = h (0x07d10001); + sa2.sin6_addr.s6_addr32[1] = 1; + sa2.sin6_addr.s6_addr32[2] = 1; + sa2.sin6_addr.s6_addr32[3] = 1; + + struct addrinfo ai2; + ai2.ai_family = AF_INET6; + ai2.ai_addr = (struct sockaddr *) &sa2; + + + struct sort_result results[2]; + + results[0].dest_addr = &ai1; + results[0].got_source_addr = true; + results[0].source_addr_len = sizeof (so1); + memcpy (&results[0].source_addr, &so1, sizeof (so1)); + + results[1].dest_addr = &ai2; + results[1].got_source_addr = true; + results[1].source_addr_len = sizeof (so2); + memcpy (&results[1].source_addr, &so2, sizeof (so2)); + + + qsort (results, 2, sizeof (results[0]), rfc3484_sort); + + int result = 0; + if (results[0].dest_addr->ai_family == AF_INET6) + { + puts ("wrong order in first test"); + result |= 1; + } + + + /* And again, this time with the reverse starting order. */ + results[1].dest_addr = &ai1; + results[1].got_source_addr = true; + results[1].source_addr_len = sizeof (so1); + memcpy (&results[1].source_addr, &so1, sizeof (so1)); + + results[0].dest_addr = &ai2; + results[0].got_source_addr = true; + results[0].source_addr_len = sizeof (so2); + memcpy (&results[0].source_addr, &so2, sizeof (so2)); + + + qsort (results, 2, sizeof (results[0]), rfc3484_sort); + + if (results[0].dest_addr->ai_family == AF_INET6) + { + puts ("wrong order in second test"); + result |= 1; + } + + return result; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/posix/tst-rfc3484.c b/posix/tst-rfc3484.c index 378e43a011..abfb76d543 100644 --- a/posix/tst-rfc3484.c +++ b/posix/tst-rfc3484.c @@ -11,9 +11,11 @@ void attribute_hidden -__check_pf (bool *p1, bool *p2) +__check_pf (bool *p1, bool *p2, struct in6addrinfo **in6ai, size_t *in6ailen) { *p1 = *p2 = true; + *in6ai = NULL; + *in6ailen = 0; } int __idna_to_ascii_lz (const char *input, char **output, int flags) diff --git a/posix/unistd.h b/posix/unistd.h index c8e8a0594a..c7a52722ca 100644 --- a/posix/unistd.h +++ b/posix/unistd.h @@ -770,8 +770,9 @@ extern int symlink (__const char *__from, __const char *__to) /* Read the contents of the symbolic link PATH into no more than LEN bytes of BUF. The contents are not null-terminated. Returns the number of characters read, or -1 for errors. */ -extern int readlink (__const char *__restrict __path, char *__restrict __buf, - size_t __len) __THROW __nonnull ((1, 2)) __wur; +extern ssize_t readlink (__const char *__restrict __path, + char *__restrict __buf, size_t __len) + __THROW __nonnull ((1, 2)) __wur; #endif /* Use BSD. */ #ifdef __USE_ATFILE @@ -780,8 +781,8 @@ extern int symlinkat (__const char *__from, int __tofd, __const char *__to) __THROW __nonnull ((1, 3)) __wur; /* Like readlink but a relative PATH is interpreted relative to FD. */ -extern int readlinkat (int __fd, __const char *__restrict __path, - char *__restrict __buf, size_t __len) +extern ssize_t readlinkat (int __fd, __const char *__restrict __path, + char *__restrict __buf, size_t __len) __THROW __nonnull ((2, 3)) __wur; #endif -- cgit v1.2.3