src/lib/misc.h
changeset 24 82cfdb6680d1
parent 6 d2036d7799fd
child 28 e944453ca924
equal deleted inserted replaced
23:1dee73ae4ad0 24:82cfdb6680d1
     1 #ifndef LIB_UTIL_H
     1 #ifndef LIB_UTIL_H
     2 #define LIB_UTIL_H
     2 #define LIB_UTIL_H
       
     3 
       
     4 #include <arpa/inet.h>
     3 
     5 
     4 /*
     6 /*
     5  * Initialize the given *value* with zeros
     7  * Initialize the given *value* with zeros
     6  */
     8  */
     7 #define ZINIT(obj) memset(&(obj), 0, sizeof((obj)))
     9 #define ZINIT(obj) memset(&(obj), 0, sizeof((obj)))
     8 
    10 
       
    11 /*
       
    12  * 64-bit hton{s,l,q}
       
    13  */
       
    14 #ifndef WORDS_BIGENDIAN /* i.e. if (little endian) */
       
    15 #define htonq(x) (((uint64_t)htonl((x)>>32))|(((uint64_t)htonl(x))<<32))
       
    16 #define ntohq(x) htonq(x)
       
    17 #else
       
    18 #define htonq(x) ((uint64_t)(x))
       
    19 #define ntohq(x) ((uint64_t)(x))
       
    20 #endif
       
    21 
       
    22 
     9 #endif /* LIB_UTIL_H */
    23 #endif /* LIB_UTIL_H */
    10 
    24