6 * endian - endian conversion macros for simple types
8 * Portable protocols (such as on-disk formats, or network protocols)
9 * are often defined to be a particular endian: little-endian (least
10 * significant bytes first) or big-endian (most significant bytes
13 * Similarly, some CPUs lay out values in memory in little-endian
14 * order (most commonly, Intel's 8086 and derivatives), or big-endian
15 * order (almost everyone else).
17 * This module provides conversion routines, inspired by the linux kernel.
22 * #include <ccan/endian/endian.h>
25 * int main(int argc, char *argv[])
30 * errx(1, "Usage: %s <value>", argv[0]);
32 * value = atoi(argv[1]);
33 * printf("native: %08x\n", value);
34 * printf("little-endian: %08x\n", cpu_to_le32(value));
35 * printf("big-endian: %08x\n", cpu_to_be32(value));
36 * printf("byte-reversed: %08x\n", bswap_32(value));
40 * License: LGPL (v2.1 or any later version)
41 * Author: Rusty Russell <rusty@rustcorp.com.au>
43 int main(int argc, char *argv[])
48 if (strcmp(argv[1], "depends") == 0)