1
1

Some (rare) platforms only have a #define for htonl and friends,

but not anything in libc.  Which causes an incorrect answer for
AC_CHECK_FUNCS.  Work around that by also checking for the
#define.

This commit was SVN r18730.
Этот коммит содержится в:
Brian Barrett 2008-06-24 23:20:25 +00:00
родитель e7a299d046
Коммит e9c50a29ba
3 изменённых файлов: 31 добавлений и 14 удалений

Просмотреть файл

@ -753,7 +753,32 @@ OMPI_CHECK_FUNC_LIB([dirname], [gen])
# Darwin doesn't need -lm, as it's a symlink to libSystem.dylib # Darwin doesn't need -lm, as it's a symlink to libSystem.dylib
OMPI_CHECK_FUNC_LIB([ceil], [m]) OMPI_CHECK_FUNC_LIB([ceil], [m])
AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf openpty isatty htonl ntohl htons ntohs getpwuid fork waitpid execve pipe ptsname setsid mmap mallopt tcgetpgrp posix_memalign strsignal sysconf syslog regcmp regexec regfree _NSGetEnviron socketpair strncpy_s _strdup usleep mkfifo]) AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf openpty isatty getpwuid fork waitpid execve pipe ptsname setsid mmap mallopt tcgetpgrp posix_memalign strsignal sysconf syslog regcmp regexec regfree _NSGetEnviron socketpair strncpy_s _strdup usleep mkfifo])
# On some hosts, htonl is a define, so the AC_CHECK_FUNC will get
# confused. On others, it's in the standard library, but stubbed with
# the magic glibc foo as not implemented. and on other systems, it's
# just not there. This covers all cases.
AC_CACHE_CHECK([for htonl define],
[ompi_cv_htonl_define],
[AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif],[
#ifndef ntohl
#error "ntohl not defined"
#endif
])], [ompi_cv_htonl_define=yes], [ompi_cv_htonl_define=no])])
AC_CHECK_FUNC([htonl], [ompi_have_htonl=yes], [ompi_have_htonl=no])
AS_IF([test "$ompi_cv_htonl_define" = "yes" -o "$ompi_have_htonl" = "yes"],
[AC_DEFINE_UNQUOTED([HAVE_UNIX_BYTESWAP], [1],
[whether unix byteswap routines -- htonl, htons, nothl, ntohs -- are available])])
# #
# Make sure we can copy va_lists (need check declared, not linkable) # Make sure we can copy va_lists (need check declared, not linkable)

Просмотреть файл

@ -80,7 +80,7 @@ typedef int opal_socklen_t;
static inline uint64_t hton64(uint64_t val) __opal_attribute_const__; static inline uint64_t hton64(uint64_t val) __opal_attribute_const__;
static inline uint64_t hton64(uint64_t val) static inline uint64_t hton64(uint64_t val)
{ {
#ifdef HAVE_HTONL #ifdef HAVE_UNIX_BYTESWAP
union { uint64_t ll; union { uint64_t ll;
uint32_t l[2]; uint32_t l[2];
} w, r; } w, r;
@ -104,7 +104,7 @@ static inline uint64_t hton64(uint64_t val)
static inline uint64_t ntoh64(uint64_t val) __opal_attribute_const__; static inline uint64_t ntoh64(uint64_t val) __opal_attribute_const__;
static inline uint64_t ntoh64(uint64_t val) static inline uint64_t ntoh64(uint64_t val)
{ {
#ifdef HAVE_NTOHL #ifdef HAVE_UNIX_BYTESWAP
union { uint64_t ll; union { uint64_t ll;
uint32_t l[2]; uint32_t l[2];
} w, r; } w, r;
@ -142,7 +142,7 @@ static inline void* ompi_ptr_ltop( uint64_t value )
return (void*)(uintptr_t) value; return (void*)(uintptr_t) value;
} }
#if defined(WORDS_BIGENDIAN) || !defined(HAVE_HTONS) || !defined(HAVE_HTONL) #if defined(WORDS_BIGENDIAN) || !defined(HAVE_UNIX_BYTESWAP)
static inline uint16_t opal_swap_bytes2(uint16_t val) __opal_attribute_const__; static inline uint16_t opal_swap_bytes2(uint16_t val) __opal_attribute_const__;
static inline uint16_t opal_swap_bytes2(uint16_t val) static inline uint16_t opal_swap_bytes2(uint16_t val)
{ {
@ -197,6 +197,6 @@ static inline uint64_t opal_swap_bytes8(uint64_t val)
#define opal_swap_bytes2 htons #define opal_swap_bytes2 htons
#define opal_swap_bytes4 htonl #define opal_swap_bytes4 htonl
#define opal_swap_bytes8 hton64 #define opal_swap_bytes8 hton64
#endif /* WORDS_BIGENDIAN || !HAVE_HTONS || !HAVE_HTONL */ #endif /* WORDS_BIGENDIAN || !HAVE_UNIX_BYTESWAP */
#endif /* OPAL_TYPES_H */ #endif /* OPAL_TYPES_H */

Просмотреть файл

@ -428,20 +428,12 @@ typedef long long bool;
* and would want to talk to the outside world... On other platforms * and would want to talk to the outside world... On other platforms
* (like Windows) we fail to detect them correctly. * (like Windows) we fail to detect them correctly.
*/ */
#ifndef __WINDOWS__ #if !defined(__WINDOWS__) && !defined(HAVE_UNIX_BYTESWAP)
#ifndef HAVE_HTONL
static inline uint32_t htonl(uint32_t hostvar) { return hostvar; } static inline uint32_t htonl(uint32_t hostvar) { return hostvar; }
#endif
#ifndef HAVE_NTOHL
static inline uint32_t ntohl(uint32_t netvar) { return netvar; } static inline uint32_t ntohl(uint32_t netvar) { return netvar; }
#endif
#ifndef HAVE_HTONS
static inline uint16_t htons(uint16_t hostvar) { return hostvar; } static inline uint16_t htons(uint16_t hostvar) { return hostvar; }
#endif
#ifndef HAVE_NTOHS
static inline uint16_t ntohs(uint16_t netvar) { return netvar; } static inline uint16_t ntohs(uint16_t netvar) { return netvar; }
#endif #endif
#endif /* WINDOWS */
/* /*
* Define __func__-preprocessor directive if the compiler does not * Define __func__-preprocessor directive if the compiler does not