| author | Tero Marttila <terom@fixme.fi> |
| Sun, 12 Oct 2008 14:57:06 +0300 | |
| changeset 24 | 82cfdb6680d1 |
| parent 6 | d2036d7799fd |
| child 28 | e944453ca924 |
| permissions | -rw-r--r-- |
|
6
d2036d7799fd
new 'simple' module, plus hello_simple
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
#ifndef LIB_UTIL_H |
|
d2036d7799fd
new 'simple' module, plus hello_simple
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
#define LIB_UTIL_H |
|
d2036d7799fd
new 'simple' module, plus hello_simple
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
|
| 24 | 4 |
#include <arpa/inet.h> |
5 |
||
|
6
d2036d7799fd
new 'simple' module, plus hello_simple
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
6 |
/* |
|
d2036d7799fd
new 'simple' module, plus hello_simple
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
7 |
* Initialize the given *value* with zeros |
|
d2036d7799fd
new 'simple' module, plus hello_simple
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
8 |
*/ |
|
d2036d7799fd
new 'simple' module, plus hello_simple
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
9 |
#define ZINIT(obj) memset(&(obj), 0, sizeof((obj))) |
|
d2036d7799fd
new 'simple' module, plus hello_simple
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
10 |
|
| 24 | 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 |
||
|
6
d2036d7799fd
new 'simple' module, plus hello_simple
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
23 |
#endif /* LIB_UTIL_H */ |
|
d2036d7799fd
new 'simple' module, plus hello_simple
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
24 |