Annotation of nono/lib/missing_endian.h, revision 1.1.1.2

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2018 [email protected]
                      4: //
                      5: 
                      6: #pragma once
                      7: 
                      8: #if !defined(_LITTLE_ENDIAN)
                      9: # define _LITTLE_ENDIAN        1234
                     10: # define _BIG_ENDIAN   4321
                     11: #endif
                     12: 
                     13: #if !defined(_BYTE_ORDER)
                     14: # if defined(WORDS_BIGENDIAN)
                     15: #  define _BYTE_ORDER _BIG_ENDIAN
                     16: # else
                     17: #  define _BYTE_ORDER _LITTLE_ENDIAN
                     18: # endif
                     19: #endif
                     20: 
1.1.1.2 ! root       21: // __builtin_bswap* がないような環境があったらその時考える
        !            22: #if !defined(HAVE___BUILTIN_BSWAP16) || \
        !            23:     !defined(HAVE___BUILTIN_BSWAP32) || \
        !            24:     !defined(HAVE___BUILTIN_BSWAP64)
        !            25: #error No __builtin_bswap*
1.1       root       26: #endif
                     27: 
                     28: #if _BYTE_ORDER == _BIG_ENDIAN
1.1.1.2 ! root       29: #define be16toh(x)     ((uint16)(x))
        !            30: #define be32toh(x)     ((uint32)(x))
        !            31: #define be64toh(x)     ((uint64)(x))
        !            32: #define le16toh(x)     __builtin_bswap16((uint16)(x))
        !            33: #define le32toh(x)     __builtin_bswap32((uint32)(x))
        !            34: #define le64toh(x)     __builtin_bswap64((uint64)(x))
1.1       root       35: #else
1.1.1.2 ! root       36: #define be16toh(x)     __builtin_bswap16((uint16)(x))
        !            37: #define be32toh(x)     __builtin_bswap32((uint32)(x))
        !            38: #define be64toh(x)     __builtin_bswap64((uint64)(x))
        !            39: #define le16toh(x)     ((uint16)(x))
        !            40: #define le32toh(x)     ((uint32)(x))
        !            41: #define le64toh(x)     ((uint64)(x))
1.1       root       42: #endif
                     43: 
1.1.1.2 ! root       44: #define htobe16(x)     be16toh(x)
        !            45: #define htobe32(x)     be32toh(x)
        !            46: #define htobe64(x)     be64toh(x)
1.1       root       47: 
1.1.1.2 ! root       48: #define htole16(x)     le16toh(x)
        !            49: #define htole32(x)     le32toh(x)
        !            50: #define htole64(x)     le64toh(x)

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.