X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fendian%2F_info.c;fp=ccan%2Fendian%2F_info.c;h=ae63e14eb53c0840860a9a5b3c833522b23c13ab;hp=0000000000000000000000000000000000000000;hb=96d128229c74480497ecb230d0e3014bbc113e95;hpb=39859e26e56171d0ebd4ee26a839e49f0db92a9c diff --git a/ccan/endian/_info.c b/ccan/endian/_info.c new file mode 100644 index 00000000..ae63e14e --- /dev/null +++ b/ccan/endian/_info.c @@ -0,0 +1,51 @@ +#include +#include +#include "config.h" + +/** + * endian - endian conversion macros for simple types + * + * Portable protocols (such as on-disk formats, or network protocols) + * are often defined to be a particular endian: little-endian (least + * significant bytes first) or big-endian (most significant bytes + * first). + * + * Similarly, some CPUs lay out values in memory in little-endian + * order (most commonly, Intel's 8086 and derivatives), or big-endian + * order (almost everyone else). + * + * This module provides conversion routines, inspired by the linux kernel. + * + * Example: + * #include + * #include + * #include + * + * // + * int main(int argc, char *argv[]) + * { + * uint32_t value; + * + * if (argc != 2) + * errx(1, "Usage: %s ", argv[0]); + * + * printf("native: %08x\n", value); + * printf("little-endian: %08x\n", cpu_to_le32(value)); + * printf("big-endian: %08x\n", cpu_to_be32(value)); + * printf("byte-reversed: %08x\n", swab_u32(value)); + * exit(0); + * } + * + * Licence: LGPL (2 or any later version) + */ +int main(int argc, char *argv[]) +{ + if (argc != 2) + return 1; + + if (strcmp(argv[1], "depends") == 0) + /* Nothing */ + return 0; + + return 1; +}