toku_htonl.h 578 Bytes
Newer Older
1 2 3
#ifndef _TOKU_HTONL_H
#define _TOKU_HTONL_H

4
#if !TOKU_WINDOWS
5 6 7
#error
#endif

8
#if defined(__cplusplus)
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
extern "C" {
#endif

#if defined(__INTEL_COMPILER)

// assume endian == LITTLE_ENDIAN

static inline uint32_t toku_htonl(uint32_t i) {
    return _bswap(i);
}

static inline uint32_t toku_ntohl(uint32_t i) {
    return _bswap(i);
}

24
#elif defined(_MSVC_VER)
25 26 27 28 29 30 31 32 33 34 35 36
#include <winsock.h>

static inline uint32_t toku_htonl(uint32_t i) {
    return htonl(i);
}

static inline uint32_t toku_ntohl(uint32_t i) {
    return ntonl(i);
}

#endif

37
#if defined(__cplusplus)
38 39 40 41
};
#endif

#endif