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.
18 * It also provides leint32_t, beint32_t etc typedefs, which are annotated for
24 * #include <ccan/endian/endian.h>
27 * int main(int argc, char *argv[])
32 * errx(1, "Usage: %s <value>", argv[0]);
34 * value = atoi(argv[1]);
35 * printf("native: %08x\n", value);
36 * printf("little-endian: %08x\n", cpu_to_le32(value));
37 * printf("big-endian: %08x\n", cpu_to_be32(value));
38 * printf("byte-reversed: %08x\n", bswap_32(value));
42 * License: License: CC0 (Public domain)
43 * Author: Rusty Russell <rusty@rustcorp.com.au>
45 int main(int argc, char *argv[])
50 if (strcmp(argv[1], "depends") == 0)