pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

corefx-git: Shim for gethostby{name,addr}



Module Name:	pkgsrc-wip
Committed By:	jasonwilliams200ok <necmon%yahoo.com@localhost>
Pushed By:	danglingpointer
Date:		Mon Feb 8 13:33:44 2016 +0000
Changeset:	52064c804a54ebf14408f5a1d3d5bfd163498b8b

Modified Files:
	corefx-git/distinfo
	corefx-git/patches/patch-src_Native_Common_pal__config.h.in
	corefx-git/patches/patch-src_Native_System.Native_pal__networking.cpp
	corefx-git/patches/patch-src_Native_configure.cmake
	corefx-git/patches/patch-src_Native_gen-buildsys-clang.sh

Log Message:
corefx-git: Shim for gethostby{name,addr}

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=52064c804a54ebf14408f5a1d3d5bfd163498b8b

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 corefx-git/distinfo                                |   8 +-
 .../patch-src_Native_Common_pal__config.h.in       |   6 +-
 ...ch-src_Native_System.Native_pal__networking.cpp | 178 +++++++++++++++++++++
 .../patches/patch-src_Native_configure.cmake       |  19 +++
 .../patches/patch-src_Native_gen-buildsys-clang.sh |   2 +-
 5 files changed, 207 insertions(+), 6 deletions(-)

diffs:
diff --git a/corefx-git/distinfo b/corefx-git/distinfo
index d42031a..3309097 100644
--- a/corefx-git/distinfo
+++ b/corefx-git/distinfo
@@ -1,8 +1,8 @@
 $NetBSD$
-SHA1 (patch-src_Native_Common_pal__config.h.in) = 723dd7903117965a2a08d53ea933190da1cb4a43
+SHA1 (patch-src_Native_Common_pal__config.h.in) = 1407a3654fd01308535ca9241152e7c26397cc22
 SHA1 (patch-src_Native_System.Native_pal__errno.cpp) = 80c19049b465824ebd518c367e228231f12b5022
 SHA1 (patch-src_Native_System.Native_pal__interfaceaddresses.cpp) = 4f82e6f028fe2b9826ba6afb62869e42a0b6ee3d
 SHA1 (patch-src_Native_System.Native_pal__mount.cpp) = 7858f5ff60fcb0d60452648aef1b1034698e2c85
-SHA1 (patch-src_Native_System.Native_pal__networking.cpp) = adc83b19e793491b1c6ea0fd8b46cd9f32e592fc
-SHA1 (patch-src_Native_configure.cmake) = 75b19df39006a76ccd60145fe98561675671fc11
-SHA1 (patch-src_Native_gen-buildsys-clang.sh) = 08d28558d0402ea8d2997ad0ff0b7a54078bd7ec
+SHA1 (patch-src_Native_System.Native_pal__networking.cpp) = 4f9b7c92c601ff7bbeb85fd6468720ade5d9a939
+SHA1 (patch-src_Native_configure.cmake) = f61be5cf28e954a0ed3cbaddddfb1d40c852b1c8
+SHA1 (patch-src_Native_gen-buildsys-clang.sh) = efc34b0da3d11b1c66625336bb4d3c7ac5273b60
diff --git a/corefx-git/patches/patch-src_Native_Common_pal__config.h.in b/corefx-git/patches/patch-src_Native_Common_pal__config.h.in
index 6f64ac2..928365a 100644
--- a/corefx-git/patches/patch-src_Native_Common_pal__config.h.in
+++ b/corefx-git/patches/patch-src_Native_Common_pal__config.h.in
@@ -10,7 +10,7 @@ $NetBSD$
  #cmakedefine01 HAVE_STRCPY_S
  #cmakedefine01 HAVE_STRLCPY
  #cmakedefine01 HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP
-@@ -15,11 +16,14 @@
+@@ -15,13 +16,18 @@
  #cmakedefine01 HAVE_IN6_U
  #cmakedefine01 HAVE_IOCTL
  #cmakedefine01 HAVE_TIOCGWINSZ
@@ -24,4 +24,8 @@ $NetBSD$
 +#cmakedefine01 HAVE_SYS_STATVFS
  #cmakedefine01 HAVE_EPOLL
  #cmakedefine01 HAVE_KQUEUE
++#cmakedefine01 HAVE_GETADDRINFO
++#cmakedefine01 HAVE_GETNAMEINFO
  #cmakedefine01 HAVE_GETHOSTBYNAME_R
+ #cmakedefine01 HAVE_GETHOSTBYADDR_R
+ #cmakedefine01 HAVE_SUPPORT_FOR_MULTIPLE_CONNECT_ATTEMPTS
diff --git a/corefx-git/patches/patch-src_Native_System.Native_pal__networking.cpp b/corefx-git/patches/patch-src_Native_System.Native_pal__networking.cpp
index afc7651..f080418 100644
--- a/corefx-git/patches/patch-src_Native_System.Native_pal__networking.cpp
+++ b/corefx-git/patches/patch-src_Native_System.Native_pal__networking.cpp
@@ -1,2 +1,180 @@
 $NetBSD$
 
+--- src/Native/System.Native/pal_networking.cpp.orig	2016-02-07 13:49:29.000000000 +0000
++++ src/Native/System.Native/pal_networking.cpp
+@@ -381,7 +381,138 @@ static void ConvertHostEntPlatformToPal(
+     }
+ }
+ 
+-#if HAVE_GETHOSTBYNAME_R
++#if defined(HAVE_GETNAMEINFO) || defined(HAVE_GETADDRINFO)
++#define BUFFER_OVERFLOW 255
++static int copy_hostent(struct hostent* from, struct hostent* to,
++                        char* buffer, size_t buflen, int* error)
++{
++    int i, len;
++    char* ptr = buffer;
++
++    *error = 0;
++    to->h_addrtype = from->h_addrtype;
++    to->h_length = from->h_length;
++    to->h_name = static_cast<char*>(ptr);
++
++    /* copy hostname to buffer */
++    len= static_cast<int>(strlen(from->h_name)+1);
++    strcpy(ptr, from->h_name);
++    ptr += len;
++
++    /* copy aliases to buffer */
++    to->h_aliases = reinterpret_cast<char**>(ptr);
++    for(i = 0; from->h_aliases[i]; i++);
++    ptr += (i+1) * static_cast<int>(sizeof(char*));
++
++    for(i = 0; from->h_aliases[i]; i++)
++    {
++        len = static_cast<int>(strlen(from->h_aliases[i])+1);
++        if (static_cast<size_t>((ptr-buffer)+len) < buflen)
++        {
++            to->h_aliases[i] = ptr;
++            strcpy(ptr, from->h_aliases[i]);
++            ptr += len;
++        }
++        else
++        {
++            *error = BUFFER_OVERFLOW;
++            return *error;
++        }
++    }
++    to->h_aliases[i] = NULL;
++
++    /* copy addr_list to buffer */
++    to->h_addr_list = reinterpret_cast<char**>(ptr);
++    for(i = 0; reinterpret_cast<int*>(from->h_addr_list[i]) != 0; i++);
++    ptr += (i+1) * static_cast<int>(sizeof(int*));
++
++    for(i = 0; reinterpret_cast<int*>(from->h_addr_list[i]) != 0; i++)
++    {
++        len = sizeof(int);
++        if (static_cast<size_t>((ptr-buffer)+len) < buflen)
++        {
++            to->h_addr_list[i] = ptr;
++            memcpy(ptr, from->h_addr_list[i], static_cast<size_t>(len));
++            ptr += len;
++        }
++        else
++        {
++            *error = BUFFER_OVERFLOW;
++            return *error;
++        }
++    }
++    to->h_addr_list[i] = 0;
++    return *error;
++}
++#endif /* defined(HAVE_GETNAMEINFO) || defined(HAVE_GETADDRINFO) */
++
++#if defined(HAVE_GETNAMEINFO)
++static int gethostbyname_r(char const* hostname, struct hostent* result,
++                                       char* buffer, size_t buflen, hostent** entry, int* error)
++{
++#ifdef HAVE_PTHREAD_H
++    if (fr_hostbyname == 0)
++    {
++        pthread_mutex_init(&fr_hostbyname_mutex, NULL);
++        fr_hostbyname = 1;
++    }
++    pthread_mutex_lock(&fr_hostbyname_mutex);
++#endif
++
++    *entry = gethostbyname(hostname);
++    if ((!(*entry)) || ((*entry)->h_addrtype != AF_INET) || ((*entry)->h_length != 4))
++    {
++         *error = h_errno;
++         *entry = NULL;
++    }
++    else
++    {
++         copy_hostent(*entry, result, buffer, buflen, error);
++         *entry = result;
++    }
++
++#ifdef HAVE_PTHREAD_H
++    pthread_mutex_unlock(&fr_hostbyname_mutex);
++#endif
++
++    return h_errno;
++}
++#endif /* defined(HAVE_GETNAMEINFO) */
++
++#if defined(HAVE_GETADDRINFO)
++static int gethostbyaddr_r(const uint8_t* addr, const socklen_t len, int type, struct hostent* result, 
++                                       char* buffer, size_t buflen, hostent** entry, int* error)
++{
++#ifdef HAVE_PTHREAD_H
++    if (fr_hostbyaddr == 0)
++    {
++        pthread_mutex_init(&fr_hostbyaddr_mutex, NULL);
++        fr_hostbyaddr = 1;
++    }
++    pthread_mutex_lock(&fr_hostbyaddr_mutex);
++#endif
++
++    *entry = gethostbyaddr(reinterpret_cast<const char*>(addr), static_cast<unsigned int>(len), type);
++    if ((!(*entry)) || ((*entry)->h_addrtype != AF_INET) || ((*entry)->h_length != 4))
++    {
++         *error = h_errno;
++         *entry = nullptr;
++    }
++    else
++    {
++         copy_hostent(*entry, result, buffer, buflen, error);
++         *entry = result;
++    }
++
++#ifdef HAVE_PTHREAD_H
++    pthread_mutex_unlock(&fr_hostbyaddr_mutex);
++#endif
++
++    return h_errno;
++}
++#endif /* defined(HAVE_GETADDRINFO) */
++
++#if defined(HAVE_GETHOSTBYNAME_R) || defined(HAVE_GETNAMEINFO)
+ static int GetHostByNameHelper(const uint8_t* hostname, hostent** entry)
+ {
+     assert(hostname != nullptr);
+@@ -421,7 +552,7 @@ static int GetHostByNameHelper(const uin
+         }
+     }
+ }
+-#endif
++#endif /* defined(HAVE_GETHOSTBYNAME_R) || defined(HAVE_GETNAMEINFO) */
+ 
+ extern "C" int32_t SystemNative_GetHostByName(const uint8_t* hostname, HostEntry* entry)
+ {
+@@ -436,7 +567,7 @@ extern "C" int32_t SystemNative_GetHostB
+ #if HAVE_THREAD_SAFE_GETHOSTBYNAME_AND_GETHOSTBYADDR
+     hostEntry = gethostbyname(reinterpret_cast<const char*>(hostname));
+     error = h_errno;
+-#elif HAVE_GETHOSTBYNAME_R
++#elif HAVE_GETHOSTBYNAME_R || HAVE_GETADDRINFO
+     error = GetHostByNameHelper(hostname, &hostEntry);
+ #else
+ #error Platform does not provide thread-safe gethostbyname
+@@ -451,7 +582,7 @@ extern "C" int32_t SystemNative_GetHostB
+     return PAL_SUCCESS;
+ }
+ 
+-#if HAVE_GETHOSTBYADDR_R
++#if defined(HAVE_GETHOSTBYADDR_R) || defined(HAVE_HOSTADDRINFO)
+ static int GetHostByAddrHelper(const uint8_t* addr, const socklen_t addrLen, int type, hostent** entry)
+ {
+     assert(addr != nullptr);
+@@ -491,7 +622,7 @@ static int GetHostByAddrHelper(const uin
+         }
+     }
+ }
+-#endif
++#endif /* defined(HAVE_GETHOSTBYADDR_R) || defined(HAVE_HOSTADDRINFO) */
+ 
+ extern "C" int32_t SystemNative_GetHostByAddress(const IPAddress* address, HostEntry* entry)
+ {
diff --git a/corefx-git/patches/patch-src_Native_configure.cmake b/corefx-git/patches/patch-src_Native_configure.cmake
index aa21d7e..626b552 100644
--- a/corefx-git/patches/patch-src_Native_configure.cmake
+++ b/corefx-git/patches/patch-src_Native_configure.cmake
@@ -61,3 +61,22 @@ $NetBSD$
      "struct in6_addr"
      __in6_u
      "netdb.h"
+@@ -157,6 +188,18 @@ check_function_exists(
+     gethostbyaddr_r
+     HAVE_GETHOSTBYADDR_R)
+ 
++check_function_exists(
++    getaddrinfo
++    HAVE_GETADDRINFO)
++
++check_function_exists(
++    gethostbyname_r
++    HAVE_GETHOSTBYNAME_R)
++
++check_function_exists(
++    getnameinfo
++    HAVE_GETNAMEINFO)
++
+ set(HAVE_SUPPORT_FOR_MULTIPLE_CONNECT_ATTEMPTS 0)
+ set(HAVE_SUPPORT_FOR_DUAL_MODE_IPV4_PACKET_INFO 0)
+ set(HAVE_THREAD_SAFE_GETHOSTBYNAME_AND_GETHOSTBYADDR 0)
diff --git a/corefx-git/patches/patch-src_Native_gen-buildsys-clang.sh b/corefx-git/patches/patch-src_Native_gen-buildsys-clang.sh
index 85e2e56..e1ed0b8 100644
--- a/corefx-git/patches/patch-src_Native_gen-buildsys-clang.sh
+++ b/corefx-git/patches/patch-src_Native_gen-buildsys-clang.sh
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- src/Native/gen-buildsys-clang.sh.orig	2016-01-30 00:20:59.000000000 +0000
+--- src/Native/gen-buildsys-clang.sh.orig	2016-02-07 13:49:29.000000000 +0000
 +++ src/Native/gen-buildsys-clang.sh
 @@ -50,4 +50,4 @@ if [[ -n "$LLDB_INCLUDE_DIR" ]]; then
      cmake_extra_defines="$cmake_extra_defines -DWITH_LLDB_INCLUDES=$LLDB_INCLUDE_DIR"


Home | Main Index | Thread Index | Old Index