Changeset 861


Ignore:
Timestamp:
Apr 24, 2006, 10:45:55 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Look for htons/htonl in netinet/in.h in addition to arpa/inet.h
  • Implement htons/htonl in common.h just in case.
Location:
libcaca/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/common.h

    r859 r861  
    3131#endif
    3232
     33#if !defined(HAVE_HTONS) && !defined(HAVE_NETINET_IN_H)
     34#   if defined(HAVE_ENDIAN_H)
     35#       include <endian.h>
     36#   endif
     37static extern inline uint16_t htons(uint16_t x)
     38{
     39#if defined(HAVE_ENDIAN_H)
     40    if(__BYTE_ORDER == __BIG_ENDIAN)
     41#else
     42    /* This is compile-time optimised with at least -O1 or -Os */
     43    uint32_t const dummy = 0x12345678;
     44    if(*(uint8_t const *)&dummy == 0x12)
     45#endif
     46        return x;
     47    else
     48        return (x >> 8) | (x << 8);
     49}
     50
     51static extern inline uint32_t htonl(uint32_t x)
     52{
     53#if defined(HAVE_ENDIAN_H)
     54    if(__BYTE_ORDER == __BIG_ENDIAN)
     55#else
     56    /* This is compile-time optimised with at least -O1 or -Os */
     57    uint32_t const dummy = 0x12345678;
     58    if(*(uint8_t const *)&dummy == 0x12)
     59#endif
     60        return x;
     61    else
     62        return (x >> 24) | ((x >> 8) & 0x0000ff00)
     63                | ((x << 8) & 0x00ff0000) | (x << 24);
     64}
     65#endif
     66
  • libcaca/trunk/configure.ac

    r859 r861  
    6262  [  --enable-doc            build documentation (needs doxygen and LaTeX)])
    6363
    64 AC_CHECK_HEADERS(stdio.h stdarg.h signal.h sys/ioctl.h sys/time.h inttypes.h endian.h unistd.h arpa/inet.h)
     64AC_CHECK_HEADERS(stdio.h stdarg.h signal.h sys/ioctl.h sys/time.h inttypes.h endian.h unistd.h arpa/inet.h netinet/in.h)
    6565AC_CHECK_FUNCS(signal ioctl vsnprintf getenv putenv strcasecmp htons)
    6666AC_CHECK_FUNCS(usleep gettimeofday)
  • libcaca/trunk/cucul/font.c

    r859 r861  
    2626#   if defined(HAVE_ARPA_INET_H)
    2727#       include <arpa/inet.h>
     28#   elif defined(HAVE_NETINET_IN_H)
     29#       include <netinet/in.h>
    2830#   endif
    2931#   include <stdio.h>
  • libcaca/trunk/tools/makefont.c

    r859 r861  
    2424#if defined(HAVE_ARPA_INET_H)
    2525#   include <arpa/inet.h>
     26#elif defined(HAVE_NETINET_IN_H)
     27#   include <netinet/in.h>
    2628#endif
    2729
Note: See TracChangeset for help on using the changeset viewer.