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

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: 
        !            21: static inline uint16 be16toh(uint16 val)
        !            22: {
        !            23: #if _BYTE_ORDER == _BIG_ENDIAN
        !            24:        return val;
        !            25: #elif defined(HAVE___BUILTIN_BSWAP16)
        !            26:        return __builtin_bswap16(val);
        !            27: #else
        !            28: #error no be16toh available
        !            29: #endif
        !            30: }
        !            31: 
        !            32: static inline uint32 be32toh(uint32 val)
        !            33: {
        !            34: #if _BYTE_ORDER == _BIG_ENDIAN
        !            35:        return val;
        !            36: #elif defined(HAVE___BUILTIN_BSWAP32)
        !            37:        return __builtin_bswap32(val);
        !            38: #else
        !            39: #error no be32toh available
        !            40: #endif
        !            41: }
        !            42: 
        !            43: static inline uint16 htobe16(uint16 val)
        !            44: {
        !            45: #if _BYTE_ORDER == _BIG_ENDIAN
        !            46:        return val;
        !            47: #elif defined(HAVE___BUILTIN_BSWAP16)
        !            48:        return __builtin_bswap16(val);
        !            49: #else
        !            50: #error no htobe16 available
        !            51: #endif
        !            52: }
        !            53: 
        !            54: static inline uint32 htobe32(uint32 val)
        !            55: {
        !            56: #if _BYTE_ORDER == _BIG_ENDIAN
        !            57:        return val;
        !            58: #elif defined(HAVE___BUILTIN_BSWAP32)
        !            59:        return __builtin_bswap32(val);
        !            60: #else
        !            61: #error no htobe32 available
        !            62: #endif
        !            63: }

unix.superglobalmegacorp.com

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